Git Product home page Git Product logo

Comments (5)

olivernn avatar olivernn commented on July 4, 2024

Yes and no. Handlebars is a JavaScript library that is a superset of the mustache syntax. On the master branch I recently made a change to the JavaScript component of poirot to make it possible to use handlebars templates. You can do this on master with the following snippet, presuming that you have included handlebars and poirot earlier.

poirot._viewFactory = function (template, partials) {
  var compiledTemplate = Handlebars.compile(template)
  return function (data) {
    return $(compiledTemplate(data))
  }
}

I'm not sure its possible to use handlebars within Rails though, as handlebars is a JavaScript library and I'm not sure a ruby version exists. I have seen it used within Rails via a JavaScript runtime such as The Ruby Racer, I'm not convinced this is a great approach though.

from poirot.

grigio avatar grigio commented on July 4, 2024

and what about <%= template_include_tag 'post_list' %> ? Will it work too?

from poirot.

olivernn avatar olivernn commented on July 4, 2024

Yep that should still work, all it does is pull the contents of a file into a script tag.

Basically everything should work apart from trying to render a handlebars template within ruby. If you do run into any issues please do let me know.

from poirot.

wolverian avatar wolverian commented on July 4, 2024

FWIW, there are a few Handlebars gems that run Handlebars.js via the_ruby_racer on the server side. That is one approach.

from poirot.

olivernn avatar olivernn commented on July 4, 2024

Yeah I have seen that, however I think its a bit of a weird way to go about it.

Ideally there would be a native ruby implementation of handlebars, if such a gem exists, or gets written, I'd incorporate that into poirot in a similar manner to how you can swap out mustache with handlebars on the client side.

from poirot.

Related Issues (18)

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.