Code Monkey home page Code Monkey logo

Comments (3)

ericf avatar ericf commented on July 29, 2024

It's possible through escaping, but this is a primary reason I created this package and I have an example for a better way of sharing templates with the client: https://github.com/ericf/express3-handlebars/tree/master/examples/advanced

Let me know if that example matches what you were looking to do.

from express-handlebars.

jonaswindey avatar jonaswindey commented on July 29, 2024

Hmm, seems my previous comment was removed?

Anyway, thanks for your example, but I think it's a bit too complex for my needs. I would just like to output in the rendered html of my .hbs file the following:

<script id="product-detail-row" type="text/x-handlebars-template">
        <tr class="product-detail-row" data-id="{{_id}}"><td>
        {{{productDetailLabel}}}
        ....
</script>

At the moment this renders an empty string instead of {{{productDetailLabel}}}, because it gets rendered by the hbs engine. Is it possible without precompiling this in your middleware method? How would you do it through escaping?

At the moment I put the contents of the script block in a separate .js file, but it would be cleaner to put this in my .hbs, since it's markup code.

Thanks

from express-handlebars.

ericf avatar ericf commented on July 29, 2024

Hmm, seems my previous comment was removed?

Not sure, I didn't remove it.

Is it possible without precompiling this in your middleware method?

I would advice that you precompile the templates because then you'd only need to use handlebars.runtime.js in the browser which is much smaller than the full handlebars.js which has the template compiler.

The Advanced Example does more stuff then what you'd probably need, here are the relevant parts:

How would you do it through escaping?

You would need to have the templates escaped on disk or process the files after you read them in, which is probably not what you'd want to do if the idea is that you're sharing these templates.

from express-handlebars.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.