Giter VIP home page Giter VIP logo

pug-rails's Introduction

๐Ÿ‘Œ Make Jade and Pug play well with Sprockets

Gem Version Build Status

About

pug-rails is a gem that allows you to easily integrate Jade / Pug template engine with Rails asset packaging system known as Sprockets.

pug-ruby is used under the hood. Please refer to the gem if you would like to use Jade / Pug compiler API directly.

Installing gem

RubyGems users

  1. Run gem install pug-rails --version "~> 3.0.0".
  2. Add require "pug-rails" to your code.

Bundler users

  1. Add to your Gemfile:
gem "pug-rails", "~> 3.0.0"
  1. Run bundle install.

Installing Jade and Pug

See installation steps and notes at pug-ruby. You may not need to do this step.

Requiring Jade runtime

Put the next line in your asset manifest:

//= require jade-runtime-1.11.0

You may change Jade runtime.js version depending on your scenario.

Naming Jade templates

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

Requiring Pug runtime

Put the next line in your asset manifest:

//= require pug-runtime-2.0.2

You may change Pug runtime.js version depending on your scenario.

IMPORTANT: You don't need to do this if you have configured Pug compiler to inline runtime functions in template. Please read about inlineRuntimeFunctions option at official website: pugjs.org.

Naming Pug templates

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

Configuring Jade / Pug

Configuration documentation is available at pug-ruby.

Configuring asset lookup paths

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

# This will add app/assets/templates to asset lookup paths.
#
# Add the next line to your initializers or application.rb:
Rails.application.config.assets.paths << Rails.root.join("app/assets/templates")

Running tests

  1. Install both Jade and Pug: npm install --global jade pug.
  2. Install gem dependencies: bundle install.
  3. Finally, run tests: bundle exec appraisal rake test.

Versioning

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

pug-rails's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

pug-rails's Issues

Not as easy as HAML?

I prefer typing PUG over HAML, mostly because I don't need to type % constantly and it feels nicer, but installing it on a simple Rails app is not as straightforward as with HAML.

With HAML, all I do is

gem 'haml', '~> 5.1.2'

And now, I can rename my views/layouts/file.html to views/layouts/file.html.haml job done

It's not working with PUG and it seems like we need to create extra files as templates with .jst. ??, am I missing something or is it really more complicated than it should be?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.