1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00
middleman--middleman/vendor/sinatra-maruku
2009-08-12 13:04:58 -07:00
..
examples add vendor back 2009-08-12 13:04:58 -07:00
lib/sinatra add vendor back 2009-08-12 13:04:58 -07:00
test add vendor back 2009-08-12 13:04:58 -07:00
LICENSE add vendor back 2009-08-12 13:04:58 -07:00
Rakefile add vendor back 2009-08-12 13:04:58 -07:00
README.markdown add vendor back 2009-08-12 13:04:58 -07:00
sinatra-maruku.gemspec add vendor back 2009-08-12 13:04:58 -07:00
VERSION.yml add vendor back 2009-08-12 13:04:58 -07:00

Sinatra Maruku Extension

The sinatra-maruku extension provides maruku helper method for rendering Maruku templates.

To install it, run:

sudo gem install wbzyl-sinatra-maruku -s http://gems.github.com

To test it, create a simple Sinatra application:

# app.rb
require 'rubygems'
require 'sinatra'
  
gem 'wbzyl-sinatra-maruku'
require 'sinatra/maruku'

get "/" do
  maruku "# Hello Maruku"
end

and run it with:

ruby app.rb

The result could be seen at http://localhost:4567.

Another example could be find in the examples directory. Run it with:

rackup -p 4567 config.ru

and visit http://localhost:4567 to contemplate the sheer beauty of rendered text written in Maruku notation.

Template Languages (update to The Sinatra Book)

Maruku Templates

This helper method:

get '/' do
  maruku :index
end

renders template ./views/index.maruku.

If a layout named layout.maruku exists, it will be used each time a template is rendered.

You can disable layouts by passing :layout => false to maruku helper. For example

get '/' do
  maruku :index, :layout => false
end

You can set a different layout from the default one with:

get '/' do
  maruku :index, :layout => :application
end

This renders ./views/index.maruku template within ./views/application.maruku layout.

Sample layout for Maruku templates

CSS: /stylesheets/application.css /stylesheets/print.css
Lang: pl
Title: Hello Maruku 
LaTeX preamble: preamble.tex

# Hello Maruku  {.header}

<%= yield %>