Comments (5)
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.
and what about <%= template_include_tag 'post_list' %> ? Will it work too?
from poirot.
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.
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.
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)
- Support partial `:locals` HOT 4
- undefined method `view_renderer' HOT 9
- segmentation fault when rendering a partial HOT 2
- make "params" available to Poirot::View subclasses HOT 2
- Poirot::View method_missing glitch
- poirot.js not loaded in Rails 3.1.1 ruby 1.8.7 HOT 3
- Use erb or haml in stache templates HOT 3
- New version of mustache.js HOT 1
- poirot not defined? HOT 1
- Accessing View Class Methods via poirot JS HOT 3
- Support partials HOT 4
- View class can't handle nested attributes HOT 2
- Poirot With Cells HOT 1
- Problem with parameterize in cucumber/selenium HOT 1
- Poirot::View does not support Rails' render
- Work with ActionMailer
- Rails 4? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from poirot.