Ruby on Rails Integration with Jade
This gem provides integration for Ruby on Rails projects with the Jade templating language.
Combined with the JST engine built in to Sprockets, you can use this gem to render Jade templates anywhere on the front end of your Rails app.
Add to your Gemfile:
gem 'jade-rails', '~> 188.8.131.52'
application.js, require the Jade runtime before any files that include
//= require jade/runtime
config.jade in your application or environment files to set compilation
options. These will be passed to the Jade compiler for all your templates.
This gem supports only a subset of the full list of Jade compiler options, because only some of them make sense for client-side compilation within Rails.
pretty: Add whitespace to the compiled HTML to make it slightly easier to read. This defaults to
truein development and
self: Use a
selfnamespace to hold locals in compiled templates. This defaults to
falsein all environments.
compile_debug: Compile templates with debugging instrumentation. (This is passed as
compileDebugto the Jade compiler.) It defaults to
truein development and
globals: This is an array of globals (as strings) that will be made available in the local scope of compiled templates. It defaults to
In addition, the
filename of the template being compiled is always passed in
to the Jade compiler options. If
compile_debug is set to
true, the filename
will be shown as part of the error output.
See the official Jade documentation for more details about these options.
AmazingProject::Application.configure do config.jade.pretty = true config.jade.compile_debug = true config.jade.globals = ['helpers'] end
h1 Jade: A Template Engine p.lead. Jade is a terse and simple templating language with a strong focus on performance and powerful features.
Then you can render this template anywhere in your JS code:
Includes are not supported. Instead, use JST along with Jade's functionality
for unescaped buffered code. For example, to "include" another template named
includes/header.jst.jade which renders with no locals, write:
bundle exec rake test
jade-rails gem version always reflects the version of Jade it contains,
with an additional number for gem-specific changes.
Always check the Jade change log when upgrading.