Created
September 11, 2012 06:21
-
-
Save getify/3696453 to your computer and use it in GitHub Desktop.
how does your templating approach handle this task?
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
{ | |
"settings" : { | |
"foo" : "low", | |
"bar" : "high", | |
"baz" : "low" | |
} | |
} |
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
<!-- | |
NOTE: see this comment for clarification of why this | |
scenario is structured this way intentionally: | |
https://gist.github.com/3696453#gistcomment-570903 | |
Scenario: | |
Given the data structure above in "1.json", how would you | |
use a templating engine to generate this snippet of html | |
as a string? NOTE: the spirit of this question is to | |
generate a string of markup with a template engine, NOT | |
to do DOM manipulation. Imagine needing to generate this | |
kind of markup server-side to send over the wire. | |
--> | |
<h1>Settings</h1> | |
<h2>foo</h2> | |
<input type="radio" name="foo" value="low" checked> low | |
<input type="radio" name="foo" value="high"> high | |
<h2>bar</h2> | |
<input type="radio" name="bar" value="low"> low | |
<input type="radio" name="bar" value="high" checked> high | |
<h2>baz</h2> | |
<input type="radio" name="baz" value="low" checked> low | |
<input type="radio" name="baz" value="high"> high | |
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
here's how "grips" template engine would handle this scenario: | |
https://gist.github.com/3706912 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks so much Patrick! Very much appreciate the input for Raptor. :)