Forums | Admin

Discussion Forums: open-discussion

Start New Thread Start New Thread
Message: 94472
BY: Thomas Leitner (gettalong)
DATE: 2010-08-09 08:34
SUBJECT: RE: ERB template

 

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.


Thread View

Thread Author Date
ERB templatevofa ethe2010-07-19 16:43
      RE: ERB templateThomas Leitner2010-08-09 08:34

Post a followup to this message