Template:Safe get
{{#vardefine:Safeget/name|{{{2}}}}}Expression error: Unrecognized punctuation character "{".
{{#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.
The above documentation is transcluded from Template:Safe get/doc. (edit | history)