pug-rails 1.11.0 → 1.11.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bec6dc4751e1b9c8b0fcdb64b5ac6a94fbfbadbb
4
- data.tar.gz: 896eeaf9c013c17ec3b3375a9aba5c0b3fea6e3a
3
+ metadata.gz: 63088a476cff59fa064af8d4ca1604dc599229f0
4
+ data.tar.gz: beaff63ef17bf550e20b7c4e059e817beb674b6c
5
5
  SHA512:
6
- metadata.gz: ee658ef508ac1de359abf6495e76faf5ec25e373bc1130c28ccf81554e679984067f1760e42e60ef7803e114fb06284ff0fb9e12205aa0440679510bd279334b
7
- data.tar.gz: ccc6f56d8a85f96845d82fed51b80dc9c4c3b967cdce2c7a5a5110049c548c91faff318a75755b1ad5de54a021374c3e4ddc0165e19f2ac759e779eb58d749fe
6
+ metadata.gz: d98ab8f6b374ce43225876e23ea00c4b3750e6f4f429f5176daba5ec19e701b96c56b9a3da0ca3110c471c026fdf25955f172aede015648c92cf474adf485ee8
7
+ data.tar.gz: 07c4177ac4daf1caa6706b07f0f531aa9a8ded036e88e4b1e4fd1bbff9b53e6f15db6fe38a6aa3a5364819b6e2ea73f75ba0979d19b89b19f9f75309b3a03913
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Ruby on Rails integration with Jade
1
+ # Ruby on Rails integration with Pug (ex. Jade)
2
2
 
3
3
  ## How it works
4
4
  This gem compiles Jade templates with [command line tool](http://jade-lang.com/command-line).
@@ -11,9 +11,9 @@ There are support of all basic features including advanced:
11
11
  Jade template can be alternatively compiled using [command line](http://jade-lang.com/command-line). This method is impemented in this fork.
12
12
 
13
13
  ## Installing
14
- Install Jade globally via npm:
14
+ Install Pug globally via npm:
15
15
  ```bash
16
- npm install -g jade
16
+ npm install -g pug-cli
17
17
  ```
18
18
 
19
19
  Add to your Gemfile:
@@ -21,9 +21,9 @@ Add to your Gemfile:
21
21
  gem 'pug-rails', '~> 1.0'
22
22
  ```
23
23
 
24
- Require Jade runtime.js:
24
+ Require Pug runtime.js:
25
25
  ```js
26
- //= require jade/runtime
26
+ //= require pug/runtime
27
27
  ```
28
28
 
29
29
  ## Running Tests
@@ -32,4 +32,4 @@ bundle exec rake test
32
32
  ```
33
33
 
34
34
  ## Versioning
35
- Gem version always reflects the version of Jade it contains.
35
+ Gem version always reflects the version of Pug it contains.
data/lib/pug-rails.rb CHANGED
@@ -1,8 +1,7 @@
1
+ # frozen_string_literal: true
1
2
  require 'open3'
2
3
  require 'tilt'
3
4
  require 'json'
4
- require 'pug/template'
5
- require 'pug/railtie' if defined?(Rails)
6
5
 
7
6
  module Pug
8
7
  class << self
@@ -11,20 +10,31 @@ module Pug
11
10
 
12
11
  # Command line arguments take precedence over json options in Jade binary
13
12
  # @link https://github.com/jadejs/jade/blob/master/bin/jade.js
14
- cmd = %w( jade )
13
+ # @link https://github.com/pugjs/pug-cli/blob/master/index.js
14
+ cmd = [ options.fetch(:executable) ]
15
15
  cmd.push('--client')
16
16
  cmd.push('--path', options[:filename]) if options[:filename]
17
17
  cmd.push('--pretty') if options[:pretty]
18
18
  cmd.push('--no-debug') unless options[:debug]
19
- cmd.push('--obj', JSON.generate(options))
19
+ cmd.push('--obj', JSON.generate(options))
20
20
 
21
21
  stdout, stderr, exit_status = Open3.capture3(*cmd, stdin_data: source)
22
22
  raise CompileError.new(stderr) unless exit_status.success?
23
23
  stdout
24
24
  end
25
+
26
+ def find_executable
27
+ %w( pug jade ).find do |name|
28
+ `which #{name}`
29
+ $?.success?
30
+ end
31
+ end
25
32
  end
26
33
 
27
34
  class CompileError < ::StandardError
28
35
  end
29
36
  end
30
37
 
38
+ require 'pug/template'
39
+ require 'pug/railtie' if defined?(Rails)
40
+
data/lib/pug/railtie.rb CHANGED
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
1
2
  module Pug
2
3
  class Railtie < Rails::Engine
3
4
  config.pug = ActiveSupport::OrderedOptions.new
5
+ config.pug.executable = Pug.find_executable
4
6
  config.pug.pretty = Rails.env.development?
5
7
  config.pug.self = false
6
8
  config.pug.compile_debug = Rails.env.development?
data/lib/pug/template.rb CHANGED
@@ -1,12 +1,11 @@
1
+ # frozen_string_literal: true
1
2
  module Pug
2
3
  class Template < Tilt::Template
3
4
  def prepare
4
5
  end
5
6
 
6
7
  def evaluate(context, locals, &block)
7
- options = { }
8
- options[:filename] = file
9
- jade_config = Rails.application.config.pug.merge(options)
8
+ jade_config = Rails.application.config.pug.merge(filename: file)
10
9
  Pug.compile(data, jade_config)
11
10
  end
12
11
  end
data/lib/pug/version.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Pug
2
- VERSION = '1.11.0'
3
+ VERSION = '1.11.0.1'
3
4
  end
data/pug-rails.gemspec CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require File.expand_path('../lib/pug/version', __FILE__)
2
3
 
3
4
  Gem::Specification.new do |s|
@@ -0,0 +1,8 @@
1
+ //- index.jade
2
+ extends ./layout.jade
3
+
4
+ block title
5
+ title Article Title
6
+
7
+ block content
8
+ h1 My Article
@@ -0,0 +1,8 @@
1
+ //- layout.jade
2
+ doctype html
3
+ html
4
+ head
5
+ block title
6
+ title Default title
7
+ body
8
+ block content
@@ -0,0 +1,3 @@
1
+ //- includes/foot.jade
2
+ #footer
3
+ p Copyright (c) foobar
@@ -0,0 +1,5 @@
1
+ //- includes/head.jade
2
+ head
3
+ title My Site
4
+ script(src='/javascripts/jquery.js')
5
+ script(src='/javascripts/app.js')
@@ -0,0 +1,8 @@
1
+ //- index.jade
2
+ doctype html
3
+ html
4
+ include ./includes/head.jade
5
+ body
6
+ h1 My Site
7
+ p Welcome to my super lame site.
8
+ include ./includes/foot.jade
@@ -0,0 +1,16 @@
1
+ doctype html
2
+ html(lang='en')
3
+ head
4
+ title=pageTitle
5
+ script(type='text/javascript').
6
+ if (foo) bar(1 + 5);
7
+ body
8
+ h1 Jade - node template engine
9
+ #container.col
10
+ if youAreUsingJade
11
+ p You are amazing
12
+ else
13
+ p Get on it!
14
+ p.
15
+ Jade is a terse and simple templating language with a
16
+ strong focus on performance and powerful features.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'pug-rails'
2
3
  require 'test/unit'
3
4
 
@@ -0,0 +1,22 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 2009-2014 TJ Holowaychuk <tj@vision-media.ca>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ 'Software'), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,252 @@
1
+ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.jade = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
+ 'use strict';
3
+
4
+ /**
5
+ * Merge two attribute objects giving precedence
6
+ * to values in object `b`. Classes are special-cased
7
+ * allowing for arrays and merging/joining appropriately
8
+ * resulting in a string.
9
+ *
10
+ * @param {Object} a
11
+ * @param {Object} b
12
+ * @return {Object} a
13
+ * @api private
14
+ */
15
+
16
+ exports.merge = function merge(a, b) {
17
+ if (arguments.length === 1) {
18
+ var attrs = a[0];
19
+ for (var i = 1; i < a.length; i++) {
20
+ attrs = merge(attrs, a[i]);
21
+ }
22
+ return attrs;
23
+ }
24
+ var ac = a['class'];
25
+ var bc = b['class'];
26
+
27
+ if (ac || bc) {
28
+ ac = ac || [];
29
+ bc = bc || [];
30
+ if (!Array.isArray(ac)) ac = [ac];
31
+ if (!Array.isArray(bc)) bc = [bc];
32
+ a['class'] = ac.concat(bc).filter(nulls);
33
+ }
34
+
35
+ for (var key in b) {
36
+ if (key != 'class') {
37
+ a[key] = b[key];
38
+ }
39
+ }
40
+
41
+ return a;
42
+ };
43
+
44
+ /**
45
+ * Filter null `val`s.
46
+ *
47
+ * @param {*} val
48
+ * @return {Boolean}
49
+ * @api private
50
+ */
51
+
52
+ function nulls(val) {
53
+ return val != null && val !== '';
54
+ }
55
+
56
+ /**
57
+ * join array as classes.
58
+ *
59
+ * @param {*} val
60
+ * @return {String}
61
+ */
62
+ exports.joinClasses = joinClasses;
63
+ function joinClasses(val) {
64
+ return (Array.isArray(val) ? val.map(joinClasses) :
65
+ (val && typeof val === 'object') ? Object.keys(val).filter(function (key) { return val[key]; }) :
66
+ [val]).filter(nulls).join(' ');
67
+ }
68
+
69
+ /**
70
+ * Render the given classes.
71
+ *
72
+ * @param {Array} classes
73
+ * @param {Array.<Boolean>} escaped
74
+ * @return {String}
75
+ */
76
+ exports.cls = function cls(classes, escaped) {
77
+ var buf = [];
78
+ for (var i = 0; i < classes.length; i++) {
79
+ if (escaped && escaped[i]) {
80
+ buf.push(exports.escape(joinClasses([classes[i]])));
81
+ } else {
82
+ buf.push(joinClasses(classes[i]));
83
+ }
84
+ }
85
+ var text = joinClasses(buf);
86
+ if (text.length) {
87
+ return ' class="' + text + '"';
88
+ } else {
89
+ return '';
90
+ }
91
+ };
92
+
93
+
94
+ exports.style = function (val) {
95
+ if (val && typeof val === 'object') {
96
+ return Object.keys(val).map(function (style) {
97
+ return style + ':' + val[style];
98
+ }).join(';');
99
+ } else {
100
+ return val;
101
+ }
102
+ };
103
+ /**
104
+ * Render the given attribute.
105
+ *
106
+ * @param {String} key
107
+ * @param {String} val
108
+ * @param {Boolean} escaped
109
+ * @param {Boolean} terse
110
+ * @return {String}
111
+ */
112
+ exports.attr = function attr(key, val, escaped, terse) {
113
+ if (key === 'style') {
114
+ val = exports.style(val);
115
+ }
116
+ if ('boolean' == typeof val || null == val) {
117
+ if (val) {
118
+ return ' ' + (terse ? key : key + '="' + key + '"');
119
+ } else {
120
+ return '';
121
+ }
122
+ } else if (0 == key.indexOf('data') && 'string' != typeof val) {
123
+ if (JSON.stringify(val).indexOf('&') !== -1) {
124
+ console.warn('Since Jade 2.0.0, ampersands (`&`) in data attributes ' +
125
+ 'will be escaped to `&amp;`');
126
+ };
127
+ if (val && typeof val.toISOString === 'function') {
128
+ console.warn('Jade will eliminate the double quotes around dates in ' +
129
+ 'ISO form after 2.0.0');
130
+ }
131
+ return ' ' + key + "='" + JSON.stringify(val).replace(/'/g, '&apos;') + "'";
132
+ } else if (escaped) {
133
+ if (val && typeof val.toISOString === 'function') {
134
+ console.warn('Jade will stringify dates in ISO form after 2.0.0');
135
+ }
136
+ return ' ' + key + '="' + exports.escape(val) + '"';
137
+ } else {
138
+ if (val && typeof val.toISOString === 'function') {
139
+ console.warn('Jade will stringify dates in ISO form after 2.0.0');
140
+ }
141
+ return ' ' + key + '="' + val + '"';
142
+ }
143
+ };
144
+
145
+ /**
146
+ * Render the given attributes object.
147
+ *
148
+ * @param {Object} obj
149
+ * @param {Object} escaped
150
+ * @return {String}
151
+ */
152
+ exports.attrs = function attrs(obj, terse){
153
+ var buf = [];
154
+
155
+ var keys = Object.keys(obj);
156
+
157
+ if (keys.length) {
158
+ for (var i = 0; i < keys.length; ++i) {
159
+ var key = keys[i]
160
+ , val = obj[key];
161
+
162
+ if ('class' == key) {
163
+ if (val = joinClasses(val)) {
164
+ buf.push(' ' + key + '="' + val + '"');
165
+ }
166
+ } else {
167
+ buf.push(exports.attr(key, val, false, terse));
168
+ }
169
+ }
170
+ }
171
+
172
+ return buf.join('');
173
+ };
174
+
175
+ /**
176
+ * Escape the given string of `html`.
177
+ *
178
+ * @param {String} html
179
+ * @return {String}
180
+ * @api private
181
+ */
182
+
183
+ var jade_encode_html_rules = {
184
+ '&': '&amp;',
185
+ '<': '&lt;',
186
+ '>': '&gt;',
187
+ '"': '&quot;'
188
+ };
189
+ var jade_match_html = /[&<>"]/g;
190
+
191
+ function jade_encode_char(c) {
192
+ return jade_encode_html_rules[c] || c;
193
+ }
194
+
195
+ exports.escape = jade_escape;
196
+ function jade_escape(html){
197
+ var result = String(html).replace(jade_match_html, jade_encode_char);
198
+ if (result === '' + html) return html;
199
+ else return result;
200
+ };
201
+
202
+ /**
203
+ * Re-throw the given `err` in context to the
204
+ * the jade in `filename` at the given `lineno`.
205
+ *
206
+ * @param {Error} err
207
+ * @param {String} filename
208
+ * @param {String} lineno
209
+ * @api private
210
+ */
211
+
212
+ exports.rethrow = function rethrow(err, filename, lineno, str){
213
+ if (!(err instanceof Error)) throw err;
214
+ if ((typeof window != 'undefined' || !filename) && !str) {
215
+ err.message += ' on line ' + lineno;
216
+ throw err;
217
+ }
218
+ try {
219
+ str = str || require('fs').readFileSync(filename, 'utf8')
220
+ } catch (ex) {
221
+ rethrow(err, null, lineno)
222
+ }
223
+ var context = 3
224
+ , lines = str.split('\n')
225
+ , start = Math.max(lineno - context, 0)
226
+ , end = Math.min(lines.length, lineno + context);
227
+
228
+ // Error context
229
+ var context = lines.slice(start, end).map(function(line, i){
230
+ var curr = i + start + 1;
231
+ return (curr == lineno ? ' > ' : ' ')
232
+ + curr
233
+ + '| '
234
+ + line;
235
+ }).join('\n');
236
+
237
+ // Alter exception message
238
+ err.path = filename;
239
+ err.message = (filename || 'Jade') + ':' + lineno
240
+ + '\n' + context + '\n\n' + err.message;
241
+ throw err;
242
+ };
243
+
244
+ exports.DebugItem = function DebugItem(lineno, filename) {
245
+ this.lineno = lineno;
246
+ this.filename = filename;
247
+ }
248
+
249
+ },{"fs":2}],2:[function(require,module,exports){
250
+
251
+ },{}]},{},[1])(1)
252
+ });
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pug-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0
4
+ version: 1.11.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaroslav Konoplov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-03 00:00:00.000000000 Z
11
+ date: 2016-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tilt
@@ -60,7 +60,6 @@ extra_rdoc_files: []
60
60
  files:
61
61
  - ".gitignore"
62
62
  - Gemfile
63
- - LICENSE
64
63
  - README.md
65
64
  - Rakefile
66
65
  - lib/pug-rails.rb
@@ -68,7 +67,15 @@ files:
68
67
  - lib/pug/template.rb
69
68
  - lib/pug/version.rb
70
69
  - pug-rails.gemspec
70
+ - test/assets/javascripts/pug/extends/index.jade
71
+ - test/assets/javascripts/pug/extends/layout.jade
72
+ - test/assets/javascripts/pug/includes/includes/foot.jade
73
+ - test/assets/javascripts/pug/includes/includes/head.jade
74
+ - test/assets/javascripts/pug/includes/index.jade
75
+ - test/assets/javascripts/pug/sample_template.jade
71
76
  - test/test-pug-rails.rb
77
+ - vendor/assets/javascripts/jade/LICENCE
78
+ - vendor/assets/javascripts/jade/runtime.js
72
79
  - vendor/assets/javascripts/pug/LICENCE
73
80
  - vendor/assets/javascripts/pug/runtime.js
74
81
  homepage: https://github.com/yivo/pug-rails
@@ -96,4 +103,10 @@ signing_key:
96
103
  specification_version: 4
97
104
  summary: Jade adapter for the Rails asset pipeline.
98
105
  test_files:
106
+ - test/assets/javascripts/pug/extends/index.jade
107
+ - test/assets/javascripts/pug/extends/layout.jade
108
+ - test/assets/javascripts/pug/includes/includes/foot.jade
109
+ - test/assets/javascripts/pug/includes/includes/head.jade
110
+ - test/assets/javascripts/pug/includes/index.jade
111
+ - test/assets/javascripts/pug/sample_template.jade
99
112
  - test/test-pug-rails.rb
data/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2014 Paul Raythattha
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.