Created
May 26, 2014 23:42
-
-
Save doowb/8004d8ee761eedf6c395 to your computer and use it in GitHub Desktop.
Calling a namespaced Handlebars helper with / in the name.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://code.jquery.com/jquery-2.1.0.min.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.js"></script> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script type="text/x-handlebars" id="tmpl"> | |
Property: {{bar}} <br /> | |
Helper: {{[a/b] bar}} | |
</script> | |
<div id="output"></div> | |
<script src="example.js"></script> | |
</body> | |
</html> |
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
$(function () { | |
Handlebars.registerHelper('a/b', function (foo) { | |
return foo; | |
}); | |
var tmpl = $('#tmpl').html(); | |
var fn = Handlebars.compile(tmpl); | |
var content = fn({bar: 'baz'}); | |
$('#output').html(content); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment