Replies: 2 comments
-
|
I usually convert my Slim templates to Pug when I need to use them client-side. It's pretty easy to do it manually as the two languages are similar (except with Pug, expressions will be interpreted as JavaScript instead of Ruby). |
Beta Was this translation helpful? Give feedback.
-
|
Not the same thing in many cases unfortunately. The main template will often refer to server-only things (like that For now I have just been keeping JS views separate, and letting the JS find the right DOM location using an id attribute. But means those things have their views separately from the main site. Also means giving JS URLs and stuff by another channel to insert into the JS template. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Often I have the need to do at least some of the rendering client side. But as well as really liking Slim's syntax, its often useful to still have a server-side pass (e.g. to make use of Rails helpers like
image_path/image_tag, route helpers, etc.).For example Ive been trying out JsRender recently, and so would be nice to be able to have Slim pass through certain things.
But the
{confuses Slim and it wont accept that indentation.{can already be disabled as an attribute wrapper, but I cant see how to treat lines or attributes starting with{as literal text up to a}, or some sort of plugin interface so I can tell Slim what to do when it encounters a{.Is there any light-weight client syntax with better compatibility?
Or scope to make it easier to tell Slim to output certain patterns as literal unescaped text in attribute and indentation contexts?
A compromise syntax style for example might be like:
Beta Was this translation helpful? Give feedback.
All reactions