How to use slim templates with backbone?
I use in my ruby-on-rails application backbone-on-rails gem that uses eco templates. But in my project I user slim templates engine and of course I want to use just one template type. But how I can switch to slim in backbone?
Gem backbone-rails from codebrew offers erb and haml, so I think I can use slim too. But how?
Fat-free client-side templates with Slim and CoffeeScript: https://github.com/jfirebaugh/skim
I think you're confusing the difference between client-side templating and server-side templating. Slim, HAML end ERB are Ruby server-side templating libraries.
Eco is a node.js server-side templating library. Templates can be compiled into client-side templates with Eco, but it is dependent on node.js to compile the templates on the server.
It's important to understand that when you create a server-side template, the rendered result generally ends up in your browser as HTML, the template itself never ends up in the browser. With client-side templating, the template itself exists on the browser and the template is rendered via JavaScript (in this case, backbone.js) to produce the HTML on page.
Related
I am using yeoman with backbone generator for front-end automation of my application.
My problem with yeoman backbone generator is when I create a backbone view with yo (yo backbone:view myView) It creates a myView.ejs template. I want it to be myView.html. I kind of got used to text.js for my backbone templates.
How can I change the default template engine used by yeoman backbone generator to text.js?
We are sorry that yeoman now doesn't support text.js. By default it will support erb. If you want you use --template-framework option to choose handlebars or mustache template framework.
Is this possible? I know people use mustache to share templates, but can you use HAML? I would prefer pre compilation.
A quick google search turns up this lib for client-side rendering of HAML . So it would appear that yes, you could share templates between the client-side and server-side of your app.
If you are processing your JS templates server-side first, then the asset pipeline will take care of this with the correct file extension. You wont be able to use the rendered haml template on the client-side though as it will be missing its tags..
I am trying to make common templates that used both by Rails and the client side, ie in coffescript.
I use hogan_assets and haml_assets to export templates to JS. However I can't find a way to use HAML and Mustache to render server-side views.
Partial solution is described here, but it doesn't work with view helpers, ie, "render partial" doesn't work.
For some unknown reason chaining of handlers, such as .mustache.haml, doesn't work, and I can't find neither good info on Rails template handler nor an example on how to build "chainable" handler.
I've been experimenting with something like smt_rails lately, but I have yet to find a silver bullet.
I'm working with a large project where the templates are written in erb. We're getting more and more into client side rendering of parts of the project and we have lots of exact duplicates in mustache of our erb templates.
I'd like to change the erb templates that are replicated in mustache to mustache and print the js templates out from those templates.
I haven't been able to figure out how to mix templating languages in rails though, is this possible? I'd rather not rewrite all the erb templates in mustache.
Thanks!
Maybe Isotope could be useful for you? I never tried it though.
I fear you'd have no direct solution...
An alternative:
You could reuse your good old html created by ruby if you insert in handlebars templates. But it's another js library...
http://www.handlebarsjs.com/
I hate to explicitly use html/css to build pages. Is there a template language I can use to semantically and quickly describe the layout and content of the page so that later I can generate html and css from it?
I'm planning to use this on a django site (but I guess if such solution already exists for RoR I can always adapt it).
Thanks.
There's GRHML, which is HAML for Genshi. (Django adapter)