Forums | Admin

Discussion Forums: open-discussion

Start New Thread Start New Thread

 

By: Thomas Leitner
RE: ERB template [ reply ]  
2010-08-09 08:34
There is not much to learn regarding ERB templates. ERB templates are just text, like this, containing specially marked up Ruby code fragments.

If you want to output something, you use '<%= ... %>' and substitute the '...' with some Ruby code. For example, '<%= Time.now %>' which outputs the current time.

If you don't want to output something but only want to use Ruby code, you use "<% ... %>". For example:

<% (1..10).each do |i| %>
Here is number: <%= i %>
<% end %>

That's it! :-)

If you want to write ERB templates for use with kramdown, you may want to know that kramdown provides two special objects in the ERB template: "doc" (contains the Kramdown::Document being converted) and "body" (the converted body).

Just have a look at the templates provided with the kramdown distribution.

By: vofa ethe
ERB template [ reply ]  
2010-07-19 16:43
Where is a good place to learn about using ERB templates?