Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/winton/stasis
Static sites made powerful
https://github.com/winton/stasis
Last synced: about 1 month ago
JSON representation
Static sites made powerful
- Host: GitHub
- URL: https://github.com/winton/stasis
- Owner: winton
- License: mit
- Created: 2011-03-08T08:15:16.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2018-01-29T01:59:36.000Z (almost 7 years ago)
- Last Synced: 2024-08-01T16:43:25.380Z (4 months ago)
- Language: Ruby
- Homepage: http://stasis.me
- Size: 394 KB
- Stars: 679
- Watchers: 13
- Forks: 56
- Open Issues: 18
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- my-awesome-github-stars - winton/stasis - Static sites made powerful (Ruby)
- awesome-static - Statis - Jan 2013), (By Language / Ruby)
README
Stasis
======Stasis is a dynamic framework for static sites.
[![Build Status](https://secure.travis-ci.org/winton/stasis.png)](http://travis-ci.org/winton/stasis)
Install
-------Install via [RubyGems](http://rubygems.org/pages/download):
$ gem install stasis
Example
-------At its most essential, Stasis takes a directory tree with [supported template files](#supported_markup_languages) and renders them.
Example directory structure:
project/
index.html.haml
images/
image.pngRun `stasis`:
$ cd project
$ stasisStasis creates a `public` directory:
project/
index.html.haml
images/
image.png
public/
index.html
images/
image.png`index.html.haml` becomes `public/index.html`.
Unrecognized extensions are copied as-is (`image.png`).
Controllers
-----------Controllers contain Ruby code that executes once before all templates render.
Example directory structure:
project/
controller.rb
index.html.haml
styles/
controller.rb
style.css.sass
You may have a controller at any directory level.
Before
------Use `before` blocks within `controller.rb` to execute code before a template renders.
`controller.rb`:
before 'index.html.haml' do
@something = true
end`@something` is now available to the `index.html.haml` template.
The `before` method can take any number of paths and/or regular expressions:
before 'index.html.haml', /.*html\.erb/ do
@something = true
endLayouts
-------`layout.html.haml`:
%html
%body= yieldIn `controller.rb`, set the default layout:
layout 'layout.html.haml'
Set the layout for a particular template:
layout 'index.html.haml' => 'layout.html.haml'
Use a regular expression:
layout /.*html.haml/ => 'layout.html.haml'
Set the layout from a `before` block:
before 'index.html.haml' do
layout 'layout.html.haml'
endRender
------Within a template:
%html
%body= render '_partial.html.haml'Within a `before` block:
before 'index.html.haml' do
@partial = render '_partial.html.haml'
endText:
render :text => 'Hello'
Local variables:
render 'index.html.haml', :locals => { :x => true }
Include a block for the template to `yield` to:
render 'index.html.haml' { 'Hello' }
Instead
-------The `instead` method changes the output of the template being rendered:
before 'index.html.haml' do
instead render('subdirectory/index.html.haml')
endHelpers
-------`controller.rb`:
helpers do
def say_hello
'Hello'
end
endThe `say_hello` method is now available to all `before` blocks and templates.
Ignore
------Use the `ignore` method in `controller.rb` to ignore certain paths.
Ignore filenames with an underscore at the beginning:
ignore /\/_.*/
Priority
--------Use the `priority` method in `controller.rb` to change the file process order.
Copy `.txt` files before rendering the `index.html.erb` template:
priority /.*txt/ => 2, 'index.html.erb' => 1
The default priority is `0` for all files.
Usage
-----### Command Line
Always execute the `stasis` command in the root directory of your project.
Development mode (auto-regenerate on save):
$ stasis -d
Specify a port to start an HTTP server:
$ stasis -d 3000
Only render specific files or directories:
$ stasis -o index.html.haml,subdirectory
Change the public (destination) directory:
$ stasis -p ../public
### Ruby LibraryInstantiate a `Stasis` object:
stasis = Stasis.new('/path/to/project/root')
Optionally specify a destination directory:
stasis = Stasis.new('/project', '/html')
Render all templates:
stasis.render
Render a specific template or directory:
stasis.render('index.html.haml', 'subdirectory')
More
----### Supported Markup Languages
Stasis uses [Tilt](https://github.com/rtomayko/tilt) to support the following template engines:
ENGINE FILE EXTENSIONS
-------------------------- -----------------------
ERB .erb, .rhtml
Interpolated String .str
Erubis .erb, .rhtml, .erubis
Haml .haml
Sass .sass
Scss .scss
Less CSS .less
Builder .builder
Liquid .liquid
RDiscount .markdown, .mkd, .md
Redcarpet .markdown, .mkd, .md
BlueCloth .markdown, .mkd, .md
Kramdown .markdown, .mkd, .md
Maruku .markdown, .mkd, .md
RedCloth .textile
RDoc .rdoc
Radius .radius
Markaby .mab
Nokogiri .nokogiri
CoffeeScript .coffee
Creole (Wiki markup) .wiki, .creole
WikiCloth (Wiki markup) .wiki, .mediawiki, .mw
Yajl .yajl### This Web Site
[Take a look at the Stasis project](https://github.com/winton/stasis/tree/master/site) that automatically generated this web site from the project [README](https://github.com/winton/stasis/blob/master/README.md).