jade-rails-adapter 1.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +35 -0
- data/Rakefile +9 -0
- data/jade-rails.gemspec +23 -0
- data/lib/jade-rails.rb +35 -0
- data/lib/jade/railtie.rb +25 -0
- data/lib/jade/template.rb +38 -0
- data/lib/jade/version.rb +3 -0
- data/test/assets/javascripts/jade/extends/index.jade +8 -0
- data/test/assets/javascripts/jade/extends/layout.jade +8 -0
- data/test/assets/javascripts/jade/includes/includes/foot.jade +3 -0
- data/test/assets/javascripts/jade/includes/includes/head.jade +5 -0
- data/test/assets/javascripts/jade/includes/index.jade +8 -0
- data/test/assets/javascripts/jade/sample_template.jade +16 -0
- data/test/test_jade-rails.rb +43 -0
- data/vendor/assets/javascripts/jade/LICENCE +22 -0
- data/vendor/assets/javascripts/jade/runtime.js +252 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6e03208ab86a7f321ba34ba631069ced5cd29b28
|
4
|
+
data.tar.gz: ec7ab4002203dfaf32d18920f0d6b91d7d0f8c5b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7277141941d39ff3d5b9c8250e19c67f10b5044aad9367ee500ef9f111a7cc3c5deea2d76cdf2bd7e1bd2004c0fb42de878333e22dd9198a3d682f3c26ab8330
|
7
|
+
data.tar.gz: 2c86544e1b34379fd29c0f1ab60627f93c56e9091cf0ba179aa90183f35e1265c592290f8a00812fbbfa6b257294ca8bb302314389a72d07e0762742807a93d8
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Ruby on Rails Integration with Jade
|
2
|
+
Forked from [mahipal/jade-rails](https://github.com/mahipal/jade-rails)
|
3
|
+
|
4
|
+
## What this fork introduces
|
5
|
+
This fork changes the way template is compiled.
|
6
|
+
It adds support of useful Jade features:
|
7
|
+
* [Jade includes](http://jade-lang.com/reference/includes)
|
8
|
+
* [Jade extends](http://jade-lang.com/reference/extends)
|
9
|
+
* [Jade inheritance](http://jade-lang.com/reference/inheritance)
|
10
|
+
|
11
|
+
## How it works
|
12
|
+
In [mahipal/jade-rails](https://github.com/mahipal/jade-rails) templates were compiled using Jade compiler with ExecJS. But ExecJS has some limitations to Node API and this restrics some Jade features.
|
13
|
+
|
14
|
+
Jade template can be alternatively compiled using [command line](http://jade-lang.com/command-line). This method is impemented in this fork.
|
15
|
+
|
16
|
+
## Installing
|
17
|
+
Install Jade globally via npm:
|
18
|
+
|
19
|
+
```bash
|
20
|
+
npm install -g jade
|
21
|
+
```
|
22
|
+
|
23
|
+
Add to your Gemfile:
|
24
|
+
```ruby
|
25
|
+
gem 'jade-rails', github: 'yivo/jade-rails'
|
26
|
+
```
|
27
|
+
|
28
|
+
Require Jade runtime.js:
|
29
|
+
|
30
|
+
```js
|
31
|
+
//= require jade/runtime
|
32
|
+
```
|
33
|
+
|
34
|
+
## Rest of README
|
35
|
+
[Check mahipal/jade-rails](https://github.com/mahipal/jade-rails#configuring)
|
data/Rakefile
ADDED
data/jade-rails.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path('../lib/jade/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'jade-rails-adapter'
|
6
|
+
s.version = Jade::VERSION
|
7
|
+
s.author = ['Paul Raythattha', 'Yaroslav Konoplov']
|
8
|
+
s.email = ['paul@appfactories.com', 'yaroslav@inbox.com']
|
9
|
+
s.summary = 'Jade adapter for the Rails asset pipeline.'
|
10
|
+
s.description = 'Jade adapter for the Rails asset pipeline.'
|
11
|
+
s.homepage = 'https://github.com/yivo/jade-rails'
|
12
|
+
s.license = 'MIT'
|
13
|
+
|
14
|
+
s.executables = `git ls-files -z -- bin/*`.split("\x0").map{ |f| File.basename(f) }
|
15
|
+
s.files = `git ls-files -z`.split("\x0")
|
16
|
+
s.test_files = `git ls-files -z -- {test,spec,features}/*`.split("\x0")
|
17
|
+
s.require_paths = ['lib']
|
18
|
+
|
19
|
+
s.add_dependency 'tilt'
|
20
|
+
|
21
|
+
s.add_development_dependency 'bundler', '~> 1.7'
|
22
|
+
s.add_development_dependency 'rake', '~> 10.0'
|
23
|
+
end
|
data/lib/jade-rails.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Jade Template Compiler for Ruby
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
require 'open3'
|
5
|
+
|
6
|
+
module Jade
|
7
|
+
class << self
|
8
|
+
|
9
|
+
def compile(source, options = {})
|
10
|
+
source = source.read if source.respond_to?(:read)
|
11
|
+
|
12
|
+
# Command line arguments take precedence over json options in Jade binary
|
13
|
+
# @link https://github.com/jadejs/jade/blob/master/bin/jade.js
|
14
|
+
cmd = %w(jade --client)
|
15
|
+
cmd.push('--path', options[:filename]) if options[:filename]
|
16
|
+
cmd.push('--pretty') if options[:pretty]
|
17
|
+
cmd.push('--no-debug') unless options[:debug]
|
18
|
+
cmd.push('--obj', JSON.generate(options))
|
19
|
+
|
20
|
+
stdout, stderr, exit_status = Open3.capture3(*cmd, stdin_data: source)
|
21
|
+
|
22
|
+
unless exit_status.success?
|
23
|
+
raise CompileError.new(stderr)
|
24
|
+
end
|
25
|
+
stdout
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
class CompileError < ::StandardError
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
require 'jade/railtie' if defined?(Rails)
|
data/lib/jade/railtie.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'jade/template'
|
2
|
+
|
3
|
+
module Jade
|
4
|
+
class Railtie < Rails::Engine
|
5
|
+
module JadeContext
|
6
|
+
attr_accessor :jade_config
|
7
|
+
end
|
8
|
+
|
9
|
+
config.jade = ActiveSupport::OrderedOptions.new
|
10
|
+
|
11
|
+
config.jade.pretty = Rails.env.development?
|
12
|
+
config.jade.self = false
|
13
|
+
config.jade.compile_debug = Rails.env.development?
|
14
|
+
config.jade.globals = []
|
15
|
+
|
16
|
+
initializer :setup_jade, after: 'sprockets.environment', group: :all do |app|
|
17
|
+
if app.assets
|
18
|
+
app.assets.register_engine '.jade', ::Jade::Template
|
19
|
+
|
20
|
+
app.assets.context_class.extend(JadeContext)
|
21
|
+
app.assets.context_class.jade_config = app.config.jade
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'tilt'
|
2
|
+
|
3
|
+
module Jade
|
4
|
+
class Template < Tilt::Template
|
5
|
+
|
6
|
+
def self.engine_initialized?
|
7
|
+
defined? ::Jade
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize_engine
|
11
|
+
require_template_library 'jade'
|
12
|
+
end
|
13
|
+
|
14
|
+
def prepare
|
15
|
+
end
|
16
|
+
|
17
|
+
# Compile template data using Jade compiler.
|
18
|
+
#
|
19
|
+
# This returns a String containing a JS function, which is intended
|
20
|
+
# to be used with the Sprockets JST engine. Name your file so that
|
21
|
+
# it is processed by both of these engines, and then the template
|
22
|
+
# will be available on the JST global on the front end.
|
23
|
+
#
|
24
|
+
# For example, `my_template.jst.jade` will be available on the front
|
25
|
+
# end as JST['my_template'], which is a function that takes a single
|
26
|
+
# argument containing the locals to use in rendering the template:
|
27
|
+
#
|
28
|
+
# # => function template(locals) { ... }
|
29
|
+
#
|
30
|
+
def evaluate(context, locals, &block)
|
31
|
+
options = { }
|
32
|
+
options[:filename] = file
|
33
|
+
jade_config = context.environment.context_class.jade_config.merge(options)
|
34
|
+
Jade.compile(data, jade_config)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
data/lib/jade/version.rb
ADDED
@@ -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.
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'jade-rails'
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
class JadeTest < Test::Unit::TestCase
|
5
|
+
JADE_TEMPLATE_FUNCTION_PATTERN = /^function\s+template\s*\(locals\)\s*\{.*\}$/m
|
6
|
+
|
7
|
+
def test_compile
|
8
|
+
template = File.read(File.expand_path('../assets/javascripts/jade/sample_template.jade', __FILE__))
|
9
|
+
result = Jade.compile(template)
|
10
|
+
assert_match(JADE_TEMPLATE_FUNCTION_PATTERN, result)
|
11
|
+
assert_no_match(/^\s*<!DOCTYPE html>/, result)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_compile_with_io
|
15
|
+
io = StringIO.new('string of jade')
|
16
|
+
assert_equal Jade.compile('string of jade'), Jade.compile(io)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_compilation_error
|
20
|
+
assert_raise Jade::CompileError do
|
21
|
+
Jade.compile <<-JADE
|
22
|
+
else
|
23
|
+
.foo
|
24
|
+
JADE
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_includes
|
29
|
+
file = File.expand_path('../assets/javascripts/jade/includes/index.jade', __FILE__)
|
30
|
+
template = File.read(file)
|
31
|
+
result = Jade.compile(template, filename: file)
|
32
|
+
assert_match(JADE_TEMPLATE_FUNCTION_PATTERN, result)
|
33
|
+
assert_no_match(/^\s*<!DOCTYPE html>/, result)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_extends
|
37
|
+
file = File.expand_path('../assets/javascripts/jade/extends/layout.jade', __FILE__)
|
38
|
+
template = File.read(file)
|
39
|
+
result = Jade.compile(template, filename: file)
|
40
|
+
assert_match(JADE_TEMPLATE_FUNCTION_PATTERN, result)
|
41
|
+
assert_no_match(/^\s*<!DOCTYPE html>/, result)
|
42
|
+
end
|
43
|
+
end
|
@@ -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 `&`');
|
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, ''') + "'";
|
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
|
+
'&': '&',
|
185
|
+
'<': '<',
|
186
|
+
'>': '>',
|
187
|
+
'"': '"'
|
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
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jade-rails-adapter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.11.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Paul Raythattha
|
8
|
+
- Yaroslav Konoplov
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-09-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: tilt
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.7'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.7'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '10.0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '10.0'
|
56
|
+
description: Jade adapter for the Rails asset pipeline.
|
57
|
+
email:
|
58
|
+
- paul@appfactories.com
|
59
|
+
- yaroslav@inbox.com
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".gitignore"
|
65
|
+
- Gemfile
|
66
|
+
- LICENSE
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- jade-rails.gemspec
|
70
|
+
- lib/jade-rails.rb
|
71
|
+
- lib/jade/railtie.rb
|
72
|
+
- lib/jade/template.rb
|
73
|
+
- lib/jade/version.rb
|
74
|
+
- test/assets/javascripts/jade/extends/index.jade
|
75
|
+
- test/assets/javascripts/jade/extends/layout.jade
|
76
|
+
- test/assets/javascripts/jade/includes/includes/foot.jade
|
77
|
+
- test/assets/javascripts/jade/includes/includes/head.jade
|
78
|
+
- test/assets/javascripts/jade/includes/index.jade
|
79
|
+
- test/assets/javascripts/jade/sample_template.jade
|
80
|
+
- test/test_jade-rails.rb
|
81
|
+
- vendor/assets/javascripts/jade/LICENCE
|
82
|
+
- vendor/assets/javascripts/jade/runtime.js
|
83
|
+
homepage: https://github.com/yivo/jade-rails
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.4.8
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: Jade adapter for the Rails asset pipeline.
|
107
|
+
test_files:
|
108
|
+
- test/assets/javascripts/jade/extends/index.jade
|
109
|
+
- test/assets/javascripts/jade/extends/layout.jade
|
110
|
+
- test/assets/javascripts/jade/includes/includes/foot.jade
|
111
|
+
- test/assets/javascripts/jade/includes/includes/head.jade
|
112
|
+
- test/assets/javascripts/jade/includes/index.jade
|
113
|
+
- test/assets/javascripts/jade/sample_template.jade
|
114
|
+
- test/test_jade-rails.rb
|