Skip to content

Latest commit

 

History

History
52 lines (42 loc) · 1.54 KB

README.md

File metadata and controls

52 lines (42 loc) · 1.54 KB

Hobbit Hole

===========

Simple gem for rendering static and mote files in hobbit. Also adds some useful shortcuts that are found in Sinatra.

Why use hobbit?

It's faster than Sinatra. In total it's less than 200 lines of code, so you can easily poke around and understand why things work the way they do.

The easiest way to get started is to use the-shire seed which has the hobbit-hole gem built in. Simply clone the repo to your projects directory, rename the folder, then cd in and run rake. You'll have to add your own git-hub remotes after that.

How to Use:

To server a static html page:

get '/' do
  render_static('index.html')
end

Useful shortcuts:

  redirect('/path')  # redirects to the given url
  session            # access the rack session
  params[:key]       # return parameter for given key

Default path for views is public/views. This is also the default path for layouts, and the default layout is layout.mote
!! NOTE currently only angular-mote syntax is supported !!

% #ruby code
% result = 2 + 2
2 + 2 = ~{result}~

To alter the default views path, default layouts path, or default layout, override the following methods in custom-hobbit.rb:

def views_path
  'public/views'
end
def layouts path
  "#{views_path}"
end
def default_layout
  "#{layouts_path}/layout.mote"
end

ToDo:

* Improve documentation * Allow for both mote AND mote-angular files.