This article serves as a reference for the file format of a blog entry. Have a look at the source of this blog entry by reading the entries/example-entry.yaml file (whose contents are shown below).
Here is the summary of this blog entry:
This is a user-defined placeholder for the summary of this blog entry. See the content of this blog entry for the real summary!
You can add arbitrary parameters to a blog entry source file (which is really a YAML file) and use them in the blog entry’s content (the text parameter).
For example, in the source of this blog entry, you will find two custom parameters whose names begin with “your_own_parameter”. To insert the values of these parameters into the blog entry’s content, we use the following eRuby directive:
<%= @entry[ 'name_of_the_parameter' ] %>
Here, we access a parameter’s value by passing the parameter’s name into the [] operator of the @entry object.
| Expression |
Result |
<%= @entry['your_own_parameter1'] %> |
hello world |
<%= @entry['your_own_parameter2'] %> |
ruby rocks! |
#
# This is a blog entry which demonstrates the file format for all blog entries.
# Blog entries are _plain text_ files marked up in YAML syntax. They are
# composed of key-value pairs, known as _parameters_, whose values are defined
# by you.
#
# The default set of parameters are shown below. Of these, only the 'name' and
# 'text' parameters are required; the other parameters are completely optional.
#
# For your convenience, the description of each parameter
# below is marked with one or more of the following emblems:
#
# * (Required) This parameter is required. If it is not present,
# then Rassmalog will ignore this blog entry file.
#
# * (Optional) This parameter is completely optional.
#
# * (eRuby) You can use eRuby directives in the value of this parameter.
#
# * (HTML) The value of this parameter will be transformed into HTML using the
# standard mechanism defined in the <tt>config/format.rb</tt> file.
#
# * (Example) This parameter is bogus; it exists
# purely for illustrative purposes.
#
# In addition to the default set of parameters, you can define and use your own
# custom parameters in this blog entry. An example of this is shown below.
#
#
# (Required) (eRuby) (HTML)
#
# The title of this blog entry.
#
name: File format of a blog entry
#
# (Optional) (eRuby)
#
# The date when this blog entry written.
#
# Here are some examples:
#
# date: Thu, 01 Jan 1970 08:00:00 GMT
# date: 1970-01-01 8:00am
# date: 1/1/1970 8:00am
# date: jan 1st 1970 16:00 -08:00
# date: 1 january 1970
# date: Wed Dec 13 21:31:04 PST 2006
#
# You can also specify dates in other languages. For
# example, the following date
#
# date: Thursday, 01 January 1970 03:15:00 PM
#
# can be written in German as:
#
# date: Donnerstag, 01 Januar 1970 15:15:00
#
# For more information about the format of this parameter, see the documentation
# for the Time.parse method by typing the following command at your terminal:
#
# ri Time.parse
#
# or by visiting the following URL:
#
# http://www.ruby-doc.org/core/classes/Time.html#M000297
#
# If you do not specify this parameter, then Rassmalog will
# use the modification time of this source file instead.
#
date: Dec 8 2006 11:00pm # put today's date and time here
#
# (Optional)
#
# The categories/labels which classify this blog entry.
#
tags:
- reference
- examples
#
# (Optional) (eRuby)
#
# A relative path (with respect to the <tt>output/</tt>
# directory) to the output HTML file for this blog entry.
#
output_file: blog-entry-file-format.html
#
# (Optional)
#
# Controls whether this entry is displayed in the
# lists of tags, archives, and recent/all entries.
#
hide: false
#
# (Optional)
#
# Overrides the *generate_toc* parameter that is defined in the main
# blog configuration file (<tt>config/blog.yaml</tt>). This parameter
# controls whether a table of contents is generated for this blog entry.
#
generate_toc: true
#
# (Optional) (eRuby) (HTML)
#
# Overrides the automatic summarization mechanism, which is
# defined in the <tt>config/entry.erb</tt> template, by allowing
# you to specify a predefined summary for this blog entry.
#
summary: |
This is a user-defined placeholder for the summary of this blog entry. See the content of this blog entry for the real summary!
#
# (Example)
#
# This is an example of how you can specify your own custom
# parameters and use them in the content of this blog entry.
#
your_own_parameter1: hello world
your_own_parameter2: ruby rocks!
#
# (Required) (eRuby) (HTML)
#
# The content of this blog entry.
#
# In this parameter, you can use the following
# predefined variables inside eRuby directives:
#
# * BLOG - data from the blog configuration file
# * LANG - data from the translation file
# * ABOUT_PAGE - the blog entry corresponding to the about page
# * SEARCH_PAGE - the blog entry corresponding to the search page
# * ENTRIES - array of all blog entries (Entry objects)
# * TAGS - array of all tags (Section objects)
# * ARCHIVES - array of all archives (Section objects)
# * FEEDS - array of all feeds (Feed objects)
# * @entry - the Entry object for which we are generating HTML
# * @summarize - should this entry be summarized?
# * @solo - is this entry being rendered alone, on its own page?
#
body: |
This article serves as a reference for the file format of a blog entry. Have a look at the source of this blog entry by reading the <tt><%= @entry.input_file %></tt> file (whose contents are "shown below":#source).
Here is the summary of this blog entry:
bq. <%= @entry['summary'] %>
h1. Adding your own parameters
You can add arbitrary parameters to a blog entry source file (which is really a YAML file) and use them in the blog entry's content (the *text* parameter).
For example, in the source of this blog entry, you will find two custom parameters whose names begin with "your_own_parameter". To insert the values of these parameters into the blog entry's content, we use the following eRuby directive:
<code lang="rhtml"><%%= @entry[ 'name_of_the_parameter' ] %></code>
Here, we access a parameter's value by passing the parameter's name into the [] operator of the @@entry@ object.
|_. Expression|_. Result|
|<code lang="rhtml"><%%= @entry['your_own_parameter1'] %></code>|<%= @entry['your_own_parameter1'] %>|
|<code lang="rhtml"><%%= @entry['your_own_parameter2'] %></code>|<%= @entry['your_own_parameter2'] %>|
h1(#source). Source of this blog entry
<pre><%=h File.read(@entry.input_file) %></pre>