-
-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to output a raw block? #73
Comments
see this Q/A on stackoverflow: http://stackoverflow.com/questions/20129909/mixing-dynamic-precompiled-handlebar-templates-using-assemble-io |
also, please reopen if you require something different |
Thanks for the quick reply! The downside of the mentioned techniques is that one couldn't reuse a template both server and client side. I ended up creating a custom helper that solved my need: https://gist.github.com/phobia/9110443 Maybe something like that could be considered as part of the helper collection for Assemble? |
Makes sense, you're just caching the partial! I don't know I didn't think of that! lol. |
@phobia I think that Handlebars will cache the compiled partial function after it's first use, so your gist might show JavaScript functions instead of just the raw partial. Also, they added a way to show output "raw" templates in alpha. You still have to wrap it in some type of helper, but you could change your helper to be a simple pass-through...
Then if someone wants it to get compiled and rendered, they use it normally... {{raw}}
<span>{{foo}}</span>
{{/raw}} If they want it to be the raw template, the use 4 mustaches {{{{#raw}}}}
<span>{{foo}}</span>
{{{{/raw}}}} |
Now that is many month later, is there an approved/official way to do this? I've upgraded assemble to use handlebars 2.0.0, but I'm not sure how to register the raw helper. in my helpers.js file I've got: module.exports.register = function (Handlebars, options) {
Handlebars.registerHelper('raw-helper', function(opts) {
return opts.fn();
});
}; But assemble is failing with:
|
I get this error too. @Ramblurr |
@jonschlinkert or @phobia Could you please reopen this bug so it will get looked at? |
Did you copy @doowb's example exactly? If so, he has a typo. It should be: {{{{#raw}}}}
<span>{{foo}}</span>
{{{{/raw}}}} That said, this really isn't an assemble issue. Assemble just runs Handlebars and reports errors. This is handlebars syntax and it's something that can be solved with handlebars helpers (but even if it can't, it still wouldn't be an assemble issue since assemble doesn't do any kind of parsing. e.g. there is nothing assemble itself can do to make that work. it has to be done in the template engine: handlebars). I don't mean that we don't like to help, of course we do. Just trying to point you in the right direction. |
In case anyone else runs into this problem within markdown content, this would be the solution: {{{{markdown}}}}{% body %}{{{{/markdown}}}} The missing |
Hi there,
I would like to output the contents of a partial (foo.hbs) in raw format:
I tried this with markdown:
and it outputs this: {{>foo}} foo.hbs Anybody could give me a hint on how to achieve this? |
Hi,
In a page I want to output a block of content without handlebars parsing anything inside it. Can it be done?
The case is that I want to embed a handlebars template for the client side javascript to use, but since some of the variables are named the same, they are parsed by handlebars through Assemble.
I'm imagining something like this:
The text was updated successfully, but these errors were encountered: