Skip to content

Commit

Permalink
clean up excess template engines
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Scott committed Feb 28, 2011
1 parent 39351ff commit c088f01
Showing 1 changed file with 0 additions and 388 deletions.
388 changes: 0 additions & 388 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -216,394 +216,6 @@ case, use <tt>:'subdir/template'</tt>). You must use a symbol because
otherwise rendering methods will render any strings passed to them
directly.

=== Haml Templates

The <tt>haml</tt> gem/library is required to render HAML templates:

# You'll need to require haml in your app
require 'haml'

get '/' do
haml :index
end

Renders <tt>./views/index.haml</tt>.

{Haml's options}[http://haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html#options]
can be set globally through Sinatra's configurations,
see {Options and Configurations}[http://www.sinatrarb.com/configuration.html],
and overridden on an individual basis.

set :haml, :format => :html5 # default Haml format is :xhtml

get '/' do
haml :index, :format => :html4 # overridden
end


=== Erb Templates

# You'll need to require erb in your app
require 'erb'

get '/' do
erb :index
end

Renders <tt>./views/index.erb</tt>.

=== Erubis Templates

The <tt>erubis</tt> gem/library is required to render Erubis templates:

# You'll need to require erubis in your app
require 'erubis'

get '/' do
erubis :index
end

Renders <tt>./views/index.erubis</tt>.

It is also possible to replace Erb with Erubis:

require 'erubis'
Tilt.register :erb, Tilt[:erubis]

get '/' do
erb :index
end

Renders <tt>./views/index.erb</tt> with Erubis.

=== Builder Templates

The <tt>builder</tt> gem/library is required to render builder templates:

# You'll need to require builder in your app
require 'builder'

get '/' do
builder :index
end

Renders <tt>./views/index.builder</tt>.

=== Nokogiri Templates

The <tt>nokogiri</tt> gem/library is required to render nokogiri templates:

# You'll need to require nokogiri in your app
require 'nokogiri'

get '/' do
nokogiri :index
end

Renders <tt>./views/index.nokogiri</tt>.

=== Sass Templates

The <tt>haml</tt> or <tt>sass</tt> gem/library is required to render Sass templates:

# You'll need to require haml or sass in your app
require 'sass'

get '/stylesheet.css' do
sass :stylesheet
end

Renders <tt>./views/stylesheet.sass</tt>.

{Sass's options}[http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#options]
can be set globally through Sinatra's configurations,
see {Options and Configurations}[http://www.sinatrarb.com/configuration.html],
and overridden on an individual basis.

set :sass, :style => :compact # default Sass style is :nested

get '/stylesheet.css' do
sass :stylesheet, :style => :expanded # overridden
end

=== Scss Templates

The <tt>haml</tt> or <tt>sass</tt> gem/library is required to render Scss templates:

# You'll need to require haml or sass in your app
require 'sass'

get '/stylesheet.css' do
scss :stylesheet
end

Renders <tt>./views/stylesheet.scss</tt>.

{Scss's options}[http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#options]
can be set globally through Sinatra's configurations,
see {Options and Configurations}[http://www.sinatrarb.com/configuration.html],
and overridden on an individual basis.

set :scss, :style => :compact # default Scss style is :nested

get '/stylesheet.css' do
scss :stylesheet, :style => :expanded # overridden
end

=== Less Templates

The <tt>less</tt> gem/library is required to render Less templates:

# You'll need to require less in your app
require 'less'

get '/stylesheet.css' do
less :stylesheet
end

Renders <tt>./views/stylesheet.less</tt>.

=== Liquid Templates

The <tt>liquid</tt> gem/library is required to render Liquid templates:

# You'll need to require liquid in your app
require 'liquid'

get '/' do
liquid :index
end

Renders <tt>./views/index.liquid</tt>.

Since you cannot call Ruby methods (except for +yield+) from a Liquid
template, you almost always want to pass locals to it:

liquid :index, :locals => { :key => 'value' }

=== Markdown Templates

The <tt>rdiscount</tt> gem/library is required to render Markdown templates:

# You'll need to require rdiscount in your app
require "rdiscount"

get '/' do
markdown :index
end

Renders <tt>./views/index.markdown</tt> (+md+ and +mkd+ are also valid file
extensions).

It is not possible to call methods from markdown, nor to pass locals to it.
You therefore will usually use it in combination with another rendering
engine:

erb :overview, :locals => { :text => markdown(:introduction) }

Note that you may also call the +markdown+ method from within other templates:

%h1 Hello From Haml!
%p= markdown(:greetings)

Since you cannot call Ruby from Markdown, you cannot use layouts written in
Markdown. However, it is possible to use another rendering engine for the
template than for the layout by passing the <tt>:layout_engine</tt> option:

get '/' do
markdown :index, :layout_engine => :erb
end

This will render <tt>./views/index.md</tt> with <tt>./views/layout.erb</tt> as
layout.

Remember that you can set such rendering options globally:

set :markdown, :layout_engine => :haml, :layout => :post

get '/' do
markdown :index
end

This will render <tt>./views/index.md</tt> (and any other Markdown template)
with <tt>./views/post.haml</tt> as layout.

It is also possible to parse Markdown with BlueCloth rather than RDiscount:

require 'bluecloth'

Tilt.register 'markdown', BlueClothTemplate
Tilt.register 'mkd', BlueClothTemplate
Tilt.register 'md', BlueClothTemplate

get '/' do
markdown :index
end

Renders <tt>./views/index.md</tt> with BlueCloth.

=== Textile Templates

The <tt>RedCloth</tt> gem/library is required to render Textile templates:

# You'll need to require redcloth in your app
require "redcloth"

get '/' do
textile :index
end

Renders <tt>./views/index.textile</tt>.

It is not possible to call methods from textile, nor to pass locals to it. You
therefore will usually use it in combination with another rendering engine:

erb :overview, :locals => { :text => textile(:introduction) }

Note that you may also call the +textile+ method from within other templates:

%h1 Hello From Haml!
%p= textile(:greetings)

Since you cannot call Ruby from Textile, you cannot use layouts written in
Textile. However, it is possible to use another rendering engine for the
template than for the layout by passing the <tt>:layout_engine</tt> option:

get '/' do
textile :index, :layout_engine => :erb
end

This will render <tt>./views/index.textile</tt> with
<tt>./views/layout.erb</tt> as layout.

Remember that you can set such rendering options globally:

set :textile, :layout_engine => :haml, :layout => :post

get '/' do
textile :index
end

This will render <tt>./views/index.textile</tt> (and any other Textile
template) with <tt>./views/post.haml</tt> as layout.

=== RDoc Templates

The <tt>rdoc</tt> gem/library is required to render RDoc templates:

# You'll need to require rdoc/markup/to_html in your app
require "rdoc/markup/to_html"

get '/' do
rdoc :index
end

Renders <tt>./views/index.rdoc</tt>.

It is not possible to call methods from rdoc, nor to pass locals to it. You
therefore will usually use it in combination with another rendering engine:

erb :overview, :locals => { :text => rdoc(:introduction) }

Note that you may also call the +rdoc+ method from within other templates:

%h1 Hello From Haml!
%p= rdoc(:greetings)

Since you cannot call Ruby from RDoc, you cannot use layouts written in
RDoc. However, it is possible to use another rendering engine for the
template than for the layout by passing the <tt>:layout_engine</tt> option:

get '/' do
rdoc :index, :layout_engine => :erb
end

This will render <tt>./views/index.rdoc</tt> with <tt>./views/layout.erb</tt> as
layout.

Remember that you can set such rendering options globally:

set :rdoc, :layout_engine => :haml, :layout => :post

get '/' do
rdoc :index
end

This will render <tt>./views/index.rdoc</tt> (and any other RDoc template)
with <tt>./views/post.haml</tt> as layout.

=== Radius Templates

The <tt>radius</tt> gem/library is required to render Radius templates:

# You'll need to require radius in your app
require 'radius'

get '/' do
radius :index
end

Renders <tt>./views/index.radius</tt>.

Since you cannot call Ruby methods (except for +yield+) from a Radius
template, you almost always want to pass locals to it:

radius :index, :locals => { :key => 'value' }

=== Markaby Templates

The <tt>markaby</tt> gem/library is required to render Markaby templates:

# You'll need to require markaby in your app
require 'markaby'

get '/' do
markaby :index
end

Renders <tt>./views/index.mab</tt>.

You may also use inline Markaby:

get '/' do
markaby { h1 "Welcome!" }
end

=== Slim Templates

The <tt>slim</tt> gem/library is required to render Slim templates:

# You'll need to require slim in your app
require 'slim'

get '/' do
slim :index
end

Renders <tt>./views/index.slim</tt>.

=== CoffeeScript Templates

The <tt>coffee-script</tt> gem/library and at least <b>one</b> of the
following options to execute JavaScript:

* +node+ (from Node.js) in your path
* you must be running on OSX
* +therubyracer+ gem/library

See http://github.com/josh/ruby-coffee-script for an updated list of options.

Now you can render CoffeeScript templates:

# You'll need to require coffee-script in your app
require 'coffee-script'

get '/application.js' do
coffee :application
end

Renders <tt>./views/application.coffee</tt>.

=== Embedded Templates

get '/' do
Expand Down

0 comments on commit c088f01

Please sign in to comment.