Template:Safe get/doc
{{#vardefine: nodoc | {{{nodoc}}} }}{{#vardefine: baddoc | {{{baddoc}}} }}
Gets a data property from a block, performing some safety checks.
{{Safe get|blockname|fieldname}}
Parameter | Function | Default value |
---|---|---|
Parameter 1 (blockname) |
The name of the block to look up data from. The exact name is best (such as "Redstone (Wire)", but redirects like "Redstone Wire" will work too. | Required value, no default. |
Parameter 2 (fieldname) |
The field to lookup. For instance, "tntres", "tool", "hardness", etc. | Required value, no default. |
Internally, this template transcludes the block page itself, passing a getter function (specifically, "Get {{{2}}}") as the first parameter. For "includable" block pages, this will result in the proper value being returned. But if the block page doesn't have properly set-up <onlyinclude></onlyinclude> guards, or it isn't actually a block page, this could result in transcluding the whole thing! This template checks the string length of the result and returns an error message to protect against this.
See Template:Block for a more thorough explanation of the general scheme.
This is the documentation page, it should be transcluded into the main template page. See Template:Doc for more information.