Save Fedia/20d41d8533e0903f0123 to your computer and use it in GitHub Desktop.
Save Fedia/20d41d8533e0903f0123 to your computer and use it in GitHub Desktop.
John Resig's Micro-Templating in 140 bytes
tmpl
John Resig's Micro-Templating in 140 bytes (138 actually).
Please see John's original article for template syntax and more examples.
with (data){ ... } implementation is longer, so the v variable must be used to access the supplied data like this: <%= v.foo || 'No foo' %>
This file contains hidden or 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
.replace(/<%(.+?)%>/g, '";$1;o+="') // other logic: <% for (;;) { %> loopy <% } %>
+ ";return o" // return the evaluated template
)
}
This file contains hidden or 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 hidden or 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
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
This file contains hidden or 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
"description": "John Resig's Micro-Templating in 140 bytes",
"keywords": [
"template",
"render",
"html",
"140bytes"
]
}
This file contains hidden or 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