Liquid - rails - render_component issue - ruby-on-rails

In my next rails project I want to use liquid pages (so that my graphic designer can do his stuff without bothering be :D) By my question is
will i be able to use
render_component and render :partial commands inside my liquid layout. If possible how
thanks in advance
cheers,
sameera

Liquid provides an include tag you can use inside a template to include external templates. However, it isn't equiparable to the render component or partial feature in Rails.
Also, render component has been deprecated times ago. You shouldn't use it.

Related

Rails 3.2+ best practice for using Haml to generate Javascript templates (JST)

I asked a specific question about problems I'm having with a specific gem intended to do this in a separate thread ( https://stackoverflow.com/q/18577033/1206117?sem=2 )
But I feel I may be on the "wrong boat" somehow because all of the questions I find about Rails/Haml/JST-templates are at least 2 years old, or go unanswered.
I'm writing an app with a lot of client-side JS and so want to use templates to render views (I'm using Backbone). I want to use Haml to write the templates.
I'm not looking for a debate about which gem/method is better, I'm looking for A WAY that works and has current support and active use. At present I cannot write my JS templates in Haml, and it's a bummer. I'm avoiding CoffeeScript at present since I'm still rather new to Javascript.
I've submitted an issue to the haml git repo.
https://github.com/haml/haml/issues/716
Looks like https://github.com/netzpirat/haml_coffee_assets gives you what you want. (window.JST templates, written in HAML, with inline coffescript support)

Sharing templates beetween JS and Rails using Haml + Mustache

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.

Rails mixing templating languages

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/

access rails image_tag helper in liquid drop

Does anyone know how to access the image_tag rails helper from within a liquid drop ?
Any help / examples would be great as i can't seem to find this anywhere!
thanks
rick
You mean the Liquid Template engine right?
If so, by design, the image_tag helper is entirely unavailable from within Liquid templates. This is the express purpose of Liquid, you aren't able to execute any Ruby code on the server running Liquid, just the set of helpers that it provides you.
If you are making a Shopify store or something like this where you are using Liquid on someone else's servers, then you are stuck manually doing what the image tag helper does normally. You have to write out <img src="{{ something.url }}>.
If you are making or running your own Rails application which uses Liquid, you can add your own image_tag style filter to Liquid so that its available for use in all your templates.
See Liquid for Programmers on the Github wiki.
Hope this helps!

Can I render a haml template with Ruby on Rails metal?

I have metal working (thanks to Railscasts), but I have a haml template that I want to render instead of just plain text. Apparently you can render ERB , but I don't see any place to do the same with haml. Is it possible or will I just have to live with using the plain rails routing if I want to continue using haml?
Thanks!
Haml, like ERB, has a Ruby interface. However, also like ERB, using it without setting up the proper template caching (as Rails normally does for you) will make it very slow, almost certainly slower than Rails' routing. So be careful, and use #def_method rather than #render.

Resources