haml_coffee_assets 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -163,11 +163,8 @@ config.hamlcoffee.format = 'xhtml'
|
|
163
163
|
|
164
164
|
### Template namespace
|
165
165
|
|
166
|
-
By default all Haml Coffee templates are registered under the `JST` namespace.
|
167
|
-
|
168
|
-
**Example:**
|
169
|
-
|
170
|
-
A template `app/assets/templates/header.hamlc` with the given content:
|
166
|
+
By default all Haml Coffee templates are registered under the `JST` namespace. A template
|
167
|
+
`app/assets/templates/header.hamlc` with the given content:
|
171
168
|
|
172
169
|
```haml
|
173
170
|
%header
|
@@ -208,7 +205,7 @@ And you must make sure `MyApp` exists before any template is loaded.
|
|
208
205
|
#### Template name
|
209
206
|
|
210
207
|
The name under which the template can be addressed in the namespace depends not only from the filename, but also on
|
211
|
-
the directory name.
|
208
|
+
the directory name by default.
|
212
209
|
|
213
210
|
The following examples assumes a configured namespace `window.JST` and the asset template directory
|
214
211
|
`app/assets/templates`:
|
@@ -217,6 +214,25 @@ The following examples assumes a configured namespace `window.JST` and the asset
|
|
217
214
|
* `app/assets/templates/users/new.hamlc` will become `JST['users/new']`
|
218
215
|
* `app/assets/templates/shared/form/address.hamlc` will become `JST['shared/form/address']`
|
219
216
|
|
217
|
+
### Basename
|
218
|
+
|
219
|
+
If you don't want to have your directory names under which your template is located to be contained in the JST name,
|
220
|
+
you can configure Haml Coffee n your `config/application.rb` to strip off the path to the file name and only use the
|
221
|
+
basename as JST name:
|
222
|
+
|
223
|
+
```ruby
|
224
|
+
config.hamlcoffee.basename = true
|
225
|
+
```
|
226
|
+
|
227
|
+
With this setting enabled the following naming rule applies:
|
228
|
+
|
229
|
+
* `app/assets/templates/login.hamlc` will become `JST['login']`
|
230
|
+
* `app/assets/templates/users/new.hamlc` will become `JST['new']`
|
231
|
+
* `app/assets/templates/shared/form/address.hamlc` will become `JST['address']`
|
232
|
+
|
233
|
+
This setting has only an effect when you're using Haml Coffee to generate the JST and not when using the Sprockets
|
234
|
+
JST processor.
|
235
|
+
|
220
236
|
### Escaping
|
221
237
|
|
222
238
|
All generated output by running CoffeeScript in your template is being escaped, but you can disable escaping of either
|
@@ -12,6 +12,7 @@ module HamlCoffeeAssets
|
|
12
12
|
:format => 'html5',
|
13
13
|
:namespace => 'window.JST',
|
14
14
|
:uglify => false,
|
15
|
+
:basename => false,
|
15
16
|
:escapeHtml => true,
|
16
17
|
:escapeAttributes => true,
|
17
18
|
:cleanValue => true,
|
@@ -39,6 +40,7 @@ module HamlCoffeeAssets
|
|
39
40
|
config.namespace = options[:namespace]
|
40
41
|
config.format = options[:format]
|
41
42
|
config.uglify = options[:uglify]
|
43
|
+
config.basename = options[:basename]
|
42
44
|
config.escapeHtml = options[:escapeHtml]
|
43
45
|
config.escapeAttributes = options[:escapeAttributes]
|
44
46
|
config.cleanValue = options[:cleanValue]
|
@@ -21,6 +21,11 @@ module HamlCoffeeAssets
|
|
21
21
|
mattr_accessor :uglify
|
22
22
|
self.uglify = false
|
23
23
|
|
24
|
+
# Ignore path when generate the JST
|
25
|
+
#
|
26
|
+
mattr_accessor :basename
|
27
|
+
self.basename = false
|
28
|
+
|
24
29
|
# Escape template code output
|
25
30
|
#
|
26
31
|
mattr_accessor :escapeHtml
|
@@ -87,7 +92,7 @@ module HamlCoffeeAssets
|
|
87
92
|
# @return [String] the compiled template in JavaScript
|
88
93
|
#
|
89
94
|
def compile(name, source, jst = true)
|
90
|
-
runtime.call('HamlCoffeeAssets.compile', name, source, jst, HamlCoffee.namespace, HamlCoffee.format, HamlCoffee.uglify,
|
95
|
+
runtime.call('HamlCoffeeAssets.compile', name, source, jst, HamlCoffee.namespace, HamlCoffee.format, HamlCoffee.uglify, HamlCoffee.basename,
|
91
96
|
HamlCoffee.escapeHtml, HamlCoffee.escapeAttributes, HamlCoffee.cleanValue,
|
92
97
|
HamlCoffee.customHtmlEscape, HamlCoffee.customCleanValue,
|
93
98
|
HamlCoffee.customPreserve, HamlCoffee.customFindAndPreserve,
|
@@ -25,6 +25,7 @@ var HamlCoffeeAssets = (function(){
|
|
25
25
|
* @param jst [Boolean] if a JST template should be generated
|
26
26
|
* @param format [String] output HTML format
|
27
27
|
* @param uglify [Boolean] skip HTML indention
|
28
|
+
* @param basename [Boolean] ignore path when generate JST
|
28
29
|
* @param escapeHtml [Boolean] whether to escape HTML output by default or not
|
29
30
|
* @param escapeAttributes [Boolean] whether to escape HTML attributes output by default or not
|
30
31
|
* @param customHtmlEscape [String] the name of the function to escape the output
|
@@ -33,7 +34,7 @@ var HamlCoffeeAssets = (function(){
|
|
33
34
|
* @param selfCloseTags [String] comma separated list of tags to self-closing tags
|
34
35
|
* @param context [String] the name of the function to merge contexts
|
35
36
|
*/
|
36
|
-
compile: function(name, source, jst, namespace, format, uglify,
|
37
|
+
compile: function(name, source, jst, namespace, format, uglify, basename,
|
37
38
|
escapeHtml, escapeAttributes, cleanValue,
|
38
39
|
customHtmlEscape, customCleanValue, customPreserve, customFindAndPreserve,
|
39
40
|
preserveTags, selfCloseTags,
|
@@ -42,6 +43,7 @@ var HamlCoffeeAssets = (function(){
|
|
42
43
|
var compiler = new Compiler({
|
43
44
|
format: format,
|
44
45
|
uglify: uglify,
|
46
|
+
basename: basename,
|
45
47
|
escapeHtml: escapeHtml,
|
46
48
|
escapeAttributes: escapeAttributes,
|
47
49
|
cleanValue: cleanValue,
|
data/lib/js/haml-coffee.js
CHANGED
@@ -342,7 +342,7 @@ require.define("/haml-coffee.js", function (require, module, exports, __dirname,
|
|
342
342
|
module.exports = HamlCoffee = (function() {
|
343
343
|
|
344
344
|
function HamlCoffee(options) {
|
345
|
-
var _base, _base2, _base3, _base4, _base5, _base6, _base7, _ref, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7;
|
345
|
+
var _base, _base2, _base3, _base4, _base5, _base6, _base7, _base8, _ref, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8;
|
346
346
|
this.options = options != null ? options : {};
|
347
347
|
if ((_ref = (_base = this.options).escapeHtml) == null) {
|
348
348
|
_base.escapeHtml = true;
|
@@ -354,14 +354,17 @@ require.define("/haml-coffee.js", function (require, module, exports, __dirname,
|
|
354
354
|
_base3.cleanValue = true;
|
355
355
|
}
|
356
356
|
if ((_ref4 = (_base4 = this.options).uglify) == null) _base4.uglify = false;
|
357
|
-
if ((_ref5 = (_base5 = this.options).
|
358
|
-
_base5.
|
357
|
+
if ((_ref5 = (_base5 = this.options).basename) == null) {
|
358
|
+
_base5.basename = false;
|
359
359
|
}
|
360
|
-
if ((_ref6 = (_base6 = this.options).
|
361
|
-
_base6.
|
360
|
+
if ((_ref6 = (_base6 = this.options).format) == null) {
|
361
|
+
_base6.format = 'html5';
|
362
362
|
}
|
363
|
-
if ((_ref7 = (_base7 = this.options).
|
364
|
-
_base7.
|
363
|
+
if ((_ref7 = (_base7 = this.options).preserveTags) == null) {
|
364
|
+
_base7.preserveTags = 'pre,textarea';
|
365
|
+
}
|
366
|
+
if ((_ref8 = (_base8 = this.options).selfCloseTags) == null) {
|
367
|
+
_base8.selfCloseTags = 'meta,img,link,br,hr,input,area,param,col,base';
|
365
368
|
}
|
366
369
|
}
|
367
370
|
|
@@ -535,7 +538,7 @@ require.define("/haml-coffee.js", function (require, module, exports, __dirname,
|
|
535
538
|
if (namespace == null) namespace = 'window.HAML';
|
536
539
|
template = '';
|
537
540
|
segments = ("" + namespace + "." + templateName).replace(/(\s|-)+/g, '_').split(/\./);
|
538
|
-
templateName = this.options.basename ? segments.pop()
|
541
|
+
templateName = this.options.basename ? segments.pop().split(/\/|\\/).pop() : segments.pop();
|
539
542
|
namespace = segments.shift();
|
540
543
|
if (segments.length !== 0) {
|
541
544
|
for (_i = 0, _len = segments.length; _i < _len; _i++) {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: haml_coffee_assets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2011-12-16 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &70224478216460 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.1'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70224478216460
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: execjs
|
27
|
-
requirement: &
|
27
|
+
requirement: &70224478215660 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 1.2.9
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70224478215660
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: bundler
|
38
|
-
requirement: &
|
38
|
+
requirement: &70224478214980 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70224478214980
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &70224478214240 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 2.7.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70224478214240
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: guard-rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &70224478212900 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 0.5.0
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70224478212900
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: yard
|
71
|
-
requirement: &
|
71
|
+
requirement: &70224478211260 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 0.7.3
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70224478211260
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: redcarpet
|
82
|
-
requirement: &
|
82
|
+
requirement: &70224478209740 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 1.17.2
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70224478209740
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: pry
|
93
|
-
requirement: &
|
93
|
+
requirement: &70224478208080 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ~>
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: 0.9.6.2
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70224478208080
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: rake
|
104
|
-
requirement: &
|
104
|
+
requirement: &70224478206860 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ~>
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
version: 0.9.2.2
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *70224478206860
|
113
113
|
description: Compile Haml CoffeeScript templates in the Rails asset pipeline.
|
114
114
|
email:
|
115
115
|
- michi@netzpiraten.ch
|