Skip to content

Instantly share code, notes, and snippets.

@eloone
Created October 7, 2013 22:19
Show Gist options
  • Save eloone/6875969 to your computer and use it in GitHub Desktop.
Save eloone/6875969 to your computer and use it in GitHub Desktop.
Print key value pairs in Handlebars
/*
data = {
ctrl_path:
{ message: 'Validator "required" failed for path ctrl_path with value ``',
name: 'ValidatorError',
path: 'ctrl_path',
type: 'required',
value: '' },
ctrl_name:
{ message: 'Validator "required" failed for path ctrl_name with value ``',
name: 'ValidatorError',
path: 'ctrl_name',
type: 'required',
value: '' },
url_schema:
{ message: 'Validator "required" failed for path url_schema with value ``',
name: 'ValidatorError',
path: 'url_schema',
type: 'required',
value: '' }
}
*/
//reserved keywords @key and this
{{#each data}}
<p class="alert-error">{{@key}} : {{this.message}}</p>
{{/each}}
/*
output :
<p class="alert-error">ctrl_path : Validator "required" failed for path ctrl_path with value ``</p>
<p class="alert-error">ctrl_name : Validator "required" failed for path ctrl_name with value ``</p>
<p class="alert-error">url_schema : Validator "required" failed for path url_schema with value ``</p>
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment