Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes #31
- Loading branch information
Showing
7 changed files
with
67 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Helpers | ||
|
||
## The `options`-parameter | ||
|
||
In addition to the parameters used in the helper-call, an `options`-object is passed to the helper as additional | ||
parameter. | ||
|
||
- `lookupProperty(object, propertyName)`: a function that returns an "own property" of an object. Whitelists specified | ||
in `allowedProtoProperties` and `allowedProtoMethods` are respected by this functions. Example: | ||
|
||
<ExamplePart examplePage="/examples/helper-lookup-property.md" show="preparationScript" /> | ||
|
||
- TODO: Describe all options that are passed to helpers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
layout: InteractivePlaygroundLayout | ||
example: | ||
template: | | ||
{{lookupOrDefault this 'firstname' 'Name not found'}} | ||
partials: | ||
preparationScript: | | ||
Handlebars.registerHelper('lookupOrDefault', function (object, propertyName, defaultValue, options) { | ||
var result = options.lookupProperty(object, propertyName) | ||
if (result != null) { | ||
return result | ||
} | ||
return defaultValue | ||
}) | ||
input: | ||
firstname: Yehuda | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters