Facing some issues while using rendering related plugins for building a basic web app #242
Replies: 7 comments 3 replies
-
Hi, I didn't have the time to investigate issues 2, 3 and 4, but regarding your first issue (escaping in haml templates), here is what I use, and it works:
I do not need the tilt gem in order for this to work, only haml gem. Hope this helps. Cheers |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Regarding the third issue, and as suggested by Jeremy, the following code removes the duplication : - content_for(:footer) do
- capture_haml { "There are #{tasks.size} tasks total" } |
Beta Was this translation helpful? Give feedback.
-
Note that - content_for :footer, "There are #{tasks.size} tasks total" This non-block form of |
Beta Was this translation helpful? Give feedback.
-
@loranger32 , @jeremyevans Thank you to both of you for your prompt replies. Using the suggestions given by both of you problems 3 and 4, in my comment #242 (comment), got resolved. @loranger32 regarding problem 1 for which you suggested to pass 1.png (home page view) 2.png (all tasks view) Any idea what can be the reason behind this and how to fix it? |
Beta Was this translation helpful? Give feedback.
-
@jiggneshhgohel yes, it now escapes everything, even legitimate html. To avoid html escaping, on places in your haml files where you trust the return value of the expression that will be evaluated, you need to replace %body<
!= yield
.footer<
!= content_for(:footer) || render('footer') |
Beta Was this translation helpful? Give feedback.
-
@loranger32 w.r.t #242 (comment) don't you think that it should prove to be better to not at all set the |
Beta Was this translation helpful? Give feedback.
-
I am trying to build a web application using Roda and as part of that I am following the section https://fiachetti.gitlab.io/mastering-roda/#rendering to render views.
While implementing a basic TODO listing I encountered some problems which are detailed ahead i.e. after the implementation I have come up with and which is shown below. Note that I prefer to write my views using HAML and thus I have configured that as the template engine for tilt.
In my Gemfile
app.rb
views/layout.haml
views/tasks/all.haml
Problems
haml
engine settingescape: true
raises errorSuch error has already been warned about in https://roda.jeremyevans.net/rdoc/classes/Roda/RodaPlugins/Render.html
for
:escape
option as quoted below (notice the part in italics):As can be seen there is a provision to deal with that limitation but I found the statement (quoted below) confusing regarding what to actually set?
So I checked the plugin code at https://github.com/jeremyevans/roda/blob/master/lib/roda/plugins/render.rb#L306.
and tried setting
escape: 'haml'
ORescape: [ 'haml' ]
but it raises the same error as shown above.So how do I get this problem solved and enable the escape option? BTW HAML's supported option for this is :escape_html.
"<Task-1>"
but this task got rendered as a tag<task-1></task-1>
whenviews/tasks/all.haml
was rendered.I guess this is done by HAML but how do we avoid this?
Note: Actually I deliberately wrapped the title in angle brackets to verify that
render
plugin escapes it ifescape
option is passed astrue
. But as I could not pass theescape
option for HAML engine this problem is secondary.content_for
plugin I encountered a problem as is commented in myviews/tasks/all.haml
shown above. What happens is that the snippet given tocontent_for
like followingfor storing against the name
:footer
and which is supposed to be rendered by the layout, it gets rendered as part ofviews/tasks/all.haml
itself and while rendering as part of the layout theviews/tasks/all.haml
markup gets rendered insider the footer div. See screenshots 1.png and 2.png below.1.png
2.png
So what could be the problem and how to resolve this?
view_options
plugin and then the/tasks
route is accessed following error is encountered:So what could be the problem and how to resolve this?
Thanks.
Beta Was this translation helpful? Give feedback.
All reactions