Pug/Jade template engine integration with Rails asset pipeline

Gem Version Build Status

About

This gem uses pug-ruby to compile Pug/Jade templates. Please refer to that gem if you want to use Pug/Jade compiler directly.

Installing gem

Add to your Gemfile:

gem 'pug-rails', '~> 2.0'

Installing Jade

Install Jade globally via npm:

npm install --global jade

Require Jade runtime.js:

//= require jade/runtime

Use .jst.jade as extension of your Jade files.

Installing Pug

Install Pug globally via npm:

npm install --global pug-cli

Require Pug runtime.js:

//= require pug/runtime

NOTE: You don't need to do this if you are inlining Pug runtime functions in template. Please read about inlineRuntimeFunctions option at official website — pugjs.org.

Use .jst.pug as extension of your Pug files.

Configuring Pug and Jade

Access Pug and Jade configurations directly:

Jade.config.compile_debug = false
Pug.config.compile_debug  = false

Access Pug and Jade configurations through Rails.application.config:

Rails.application.config.jade.compile_debug = false
Rails.application.config.pug.compile_debug  = false

Configuring asset lookup paths

It doesn't matter where to put Pug/Jade files but don't forget to update asset lookup paths. Personally I prefer to put templates in app/assets/templates:

# Add app/assets/templates to asset lookup paths
# Add this to your initializers or application.rb
Rails.application.config.assets.paths << Rails.root.join('app/assets/templates')

Running Tests

Install bundler:

gem install bundler

Install dependencies:

cd pug-rails && bundle && appraisal install

Run tests:

cd pug-rails && appraisal rake test

To test pug-ruby — refer to pug-ruby

Versioning

Prior to version 2.0 version of the gem was the same as the version of the Jade runtime that it contains.