Stencil
Compiler to help you get started building a new web site, web application or HTML email fast.
Installation
gem install stencil-ruby
Commands
Build
Renders HTML and CSS into the build directory
Command: stencil build
Watch
Watches for changes to files and compiles them. Serves the build folder at
http://localhost:3000/
Command: stencil watch
New
Creates a new folder with the latest version of stencil
Command: stencil new project-name
Inline
Inlines the CSS in all email files in the build directory (prefixed by email-
)
Command: stencil inline
Run stencil help
for a full list of commands.
Deploy
Deploys the build folder to gh-pages. You can optionally pass through a different remote, the default is origin.
Command: stencil deploy
Getting Started
New Project
- Run
stencil new your-project-name
- Cd into your-project-name
- Run
stencil watch
- …
- Count cash!
Existing Project
- Ensure you have the correct folder structure (see below)
- Run
stencil watch
- …
- Count cash!
How it works
Stencil is created for a very specific workflow. Everything is compiled flat
into the build
folder to allow easy transportation or deployment to almost
any environment.
Folder Structure
project
├── assets
│ ├── stylesheets
│ │ └── application.scss
│ └── javascripts
│ └── lib
│
├── build
│
├── templates
│
└── emails
Assets
Stylesheets
Stencil looks for an application.scss
file inside assets/stylesheets
and
compiles this to build/application.css
.
JavaScript
Stencil will combine and minify everything inside the assets/javascripts
folder into build/application.js
.
Sub folders will be compiled first and everything is sorted in alphabetical order.
Build
The build directory is where all compiled files are saved.
Templates
Templates should include liquid files which are compiled into the build/
folder.
Stencil will look for a layout file at templats/_layout.liquid
and compile
every template inside this file.
You can include liquid partials saved in the templates
folder using the standard liquid {% include 'file' %}
tags.
Emails
Emails should include liquid files which are compiled into the build/
folder.
Emails will automatically be appended with email-
when they are compiled.
Any file in the build
directory prefixed with email-
will be inlined when
using the stencil inline
command.
Help
Server stuck?
- Run
lsof -wni tcp:3000
- Run
kill -9 PID
(where the PID is from the output above)
Building Locally
- Clone it
- Run
bundle
- Run
rake install
Contributing
- Fork it ( https://github.com/micdijkstra/stencil/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request