syntax.us
Let the syntax do the talking
![]() |
Blog Contact Posts Questions Tags Hire Me |
Question:
In Rails, how to read a HAML file into an HTML-code-element?
Recently I encountered a use-case which asked me to read a HAML file into an HTML-code-element. After a bit of thought I decided it was similar to this question: In Ruby, how to read a file into a String object? I knew this because it is easy to render any Ruby string with ERB syntax. I typed that question into Google: http://www.google.com/search?q=In+Ruby,+how+to+read+a+file+into+a+String+object I found this syntax example:
I put it to use in a Rails partial like this:
The result can be seen at this URL:
code_challenge2015_1018 The next step in this idea is to ask IO.binread() to read from a git-repository rather than a folder. This enhancement would allow my Rails app to display the most recent HAML file rather than an artifact from the past. |
syntax.us Let the syntax do the talking |
Blog Contact Posts Questions Tags Hire Me |