haml_coffee_assets 0.9.1 → 0.9.2
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.
- data/README.md +11 -18
- data/lib/haml_coffee_assets.rb +22 -6
- data/lib/haml_coffee_assets/compiler.rb +85 -0
- data/lib/haml_coffee_assets/configuration.rb +108 -0
- data/lib/haml_coffee_assets/rails/engine.rb +30 -0
- data/lib/haml_coffee_assets/tilt/template_handler.rb +48 -0
- data/lib/haml_coffee_assets/version.rb +1 -1
- data/lib/js/coffee-script.js +2 -2
- data/lib/{haml_coffee_assets → js}/haml_coffee_assets.js +1 -1
- data/lib/js/{haml-coffee.js → hamlcoffee.js} +165 -92
- data/vendor/assets/javascripts/hamlcoffee.js.coffee.erb +98 -119
- metadata +9 -121
- data/lib/haml_coffee_assets/engine.rb +0 -64
- data/lib/haml_coffee_assets/haml_coffee.rb +0 -176
- data/lib/haml_coffee_assets/haml_coffee_template.rb +0 -52
- data/lib/tasks/haml-coffee-rails_tasks.rake +0 -4
@@ -1,121 +1,100 @@
|
|
1
|
-
<% configuration = HamlCoffeeAssets::HamlCoffee.configuration || HamlCoffeeAssets::HamlCoffee::Configuration.new %>
|
2
|
-
|
3
1
|
# HAML Coffee namespace
|
4
2
|
#
|
5
|
-
window.HAML
|
6
|
-
|
7
|
-
# HAML Coffee html escape function
|
8
|
-
#
|
9
|
-
# @param text [String] the text to escape
|
10
|
-
# @return [String] the escaped text
|
11
|
-
#
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
# HAML Coffee clean value function
|
20
|
-
#
|
21
|
-
# @param text [String] the text to be cleaned
|
22
|
-
# @return [String] the cleaned text
|
23
|
-
#
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
#
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
#
|
66
|
-
#
|
67
|
-
#
|
68
|
-
|
69
|
-
|
70
|
-
#
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
#
|
75
|
-
#
|
76
|
-
# @param
|
77
|
-
# @
|
78
|
-
#
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
#
|
85
|
-
#
|
86
|
-
#
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
#
|
95
|
-
#
|
96
|
-
#
|
97
|
-
# @param [
|
98
|
-
# @
|
99
|
-
#
|
100
|
-
|
101
|
-
start
|
102
|
-
|
103
|
-
# The succeed helper appends text to the function output
|
104
|
-
# without whitespace in between.
|
105
|
-
#
|
106
|
-
# @param [String] end the text to append to the text
|
107
|
-
# @param [Function] fn the text generating function
|
108
|
-
# @return [String] the succeeded text
|
109
|
-
#
|
110
|
-
window.HAML.succeed ||= (end, fn) ->
|
111
|
-
fn() + end
|
112
|
-
|
113
|
-
# The precede helper prepends text to the function output
|
114
|
-
# without whitespace in between.
|
115
|
-
#
|
116
|
-
# @param [String] start the text to prepend to the text
|
117
|
-
# @param [Function] fn the text generating function
|
118
|
-
# @return [String] the preeceded text
|
119
|
-
#
|
120
|
-
window.HAML.precede ||= (start, fn) ->
|
121
|
-
start + fn()
|
3
|
+
class window.HAML
|
4
|
+
|
5
|
+
# HAML Coffee html escape function
|
6
|
+
#
|
7
|
+
# @param text [String] the text to escape
|
8
|
+
# @return [String] the escaped text
|
9
|
+
#
|
10
|
+
@escape: (text) ->
|
11
|
+
("" + text)
|
12
|
+
.replace(/&/g, "&")
|
13
|
+
.replace(/</g, "<")
|
14
|
+
.replace(/>/g, ">")
|
15
|
+
.replace(/"/g, """)
|
16
|
+
|
17
|
+
# HAML Coffee clean value function
|
18
|
+
#
|
19
|
+
# @param text [String] the text to be cleaned
|
20
|
+
# @return [String] the cleaned text
|
21
|
+
#
|
22
|
+
@cleanValue: (text) ->
|
23
|
+
if text is null or text is undefined then '' else text
|
24
|
+
|
25
|
+
# Extends an object with the properties from
|
26
|
+
# the source objects.
|
27
|
+
#
|
28
|
+
# @param [Object] obj the object to extended
|
29
|
+
# @param [Object] sources the objects to copy from
|
30
|
+
# @return [Object] the extended object
|
31
|
+
#
|
32
|
+
@extend: (obj, sources...) ->
|
33
|
+
for source in sources
|
34
|
+
obj[key] = val for key, val of source
|
35
|
+
|
36
|
+
obj
|
37
|
+
|
38
|
+
# HAML Coffee global template context.
|
39
|
+
#
|
40
|
+
# @return [Object] the global template context
|
41
|
+
#
|
42
|
+
@globals: -> {}
|
43
|
+
|
44
|
+
# Get the HAML template context. This merges the local
|
45
|
+
# and the global template context into a new context.
|
46
|
+
#
|
47
|
+
# @param locals [Object] the local template context
|
48
|
+
# @return [Object] the merged context
|
49
|
+
#
|
50
|
+
@context: (locals) ->
|
51
|
+
@extend {}, HAML.globals(), locals
|
52
|
+
|
53
|
+
# Preserve newlines in the text
|
54
|
+
#
|
55
|
+
# @param text [String] the text to preserve
|
56
|
+
# @return [String] the preserved text
|
57
|
+
#
|
58
|
+
@preserve: (text) ->
|
59
|
+
text.replace /\n/g, '
'
|
60
|
+
|
61
|
+
# Find and preserve newlines in the preserving tags
|
62
|
+
#
|
63
|
+
# @param text [String] the text to preserve
|
64
|
+
# @return [String] the preserved text
|
65
|
+
#
|
66
|
+
@findAndPreserve: (text) ->
|
67
|
+
tags = '<%= HamlCoffeeAssets.config.preserveTags %>'.split(',').join('|')
|
68
|
+
text = text.replace ///<(#{ tags })>([^]*?)<\/\1>///g, (str, tag, content) ->
|
69
|
+
"<#{ tag }>#{ <%= HamlCoffeeAssets.config.customPreserve %>(content) }</#{ tag }>"
|
70
|
+
|
71
|
+
# The surround helper surrounds the function output
|
72
|
+
# with the start and end string without whitespace in between.
|
73
|
+
#
|
74
|
+
# @param [String] start the text to prepend to the text
|
75
|
+
# @param [String] end the text to append to the text
|
76
|
+
# @param [Function] fn the text generating function
|
77
|
+
# @return [String] the surrounded text
|
78
|
+
#
|
79
|
+
@surround: (start, end, fn) ->
|
80
|
+
start + fn() + end
|
81
|
+
|
82
|
+
# The succeed helper appends text to the function output
|
83
|
+
# without whitespace in between.
|
84
|
+
#
|
85
|
+
# @param [String] end the text to append to the text
|
86
|
+
# @param [Function] fn the text generating function
|
87
|
+
# @return [String] the succeeded text
|
88
|
+
#
|
89
|
+
@succeed: (end, fn) ->
|
90
|
+
fn() + end
|
91
|
+
|
92
|
+
# The precede helper prepends text to the function output
|
93
|
+
# without whitespace in between.
|
94
|
+
#
|
95
|
+
# @param [String] start the text to prepend to the text
|
96
|
+
# @param [Function] fn the text generating function
|
97
|
+
# @return [String] the preeceded text
|
98
|
+
#
|
99
|
+
@precede: (start, fn) ->
|
100
|
+
start + fn()
|
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.9.
|
4
|
+
version: 0.9.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: execjs
|
@@ -75,118 +75,6 @@ dependencies:
|
|
75
75
|
- - ! '>='
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: railties
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - ! '>='
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '3.1'
|
86
|
-
type: :development
|
87
|
-
prerelease: false
|
88
|
-
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ! '>='
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: '3.1'
|
94
|
-
- !ruby/object:Gem::Dependency
|
95
|
-
name: rspec
|
96
|
-
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
|
-
requirements:
|
99
|
-
- - ! '>='
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: '0'
|
102
|
-
type: :development
|
103
|
-
prerelease: false
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
|
-
requirements:
|
107
|
-
- - ! '>='
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
110
|
-
- !ruby/object:Gem::Dependency
|
111
|
-
name: guard-rspec
|
112
|
-
requirement: !ruby/object:Gem::Requirement
|
113
|
-
none: false
|
114
|
-
requirements:
|
115
|
-
- - ! '>='
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
none: false
|
122
|
-
requirements:
|
123
|
-
- - ! '>='
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
version: '0'
|
126
|
-
- !ruby/object:Gem::Dependency
|
127
|
-
name: yard
|
128
|
-
requirement: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
|
-
requirements:
|
131
|
-
- - ! '>='
|
132
|
-
- !ruby/object:Gem::Version
|
133
|
-
version: '0'
|
134
|
-
type: :development
|
135
|
-
prerelease: false
|
136
|
-
version_requirements: !ruby/object:Gem::Requirement
|
137
|
-
none: false
|
138
|
-
requirements:
|
139
|
-
- - ! '>='
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
version: '0'
|
142
|
-
- !ruby/object:Gem::Dependency
|
143
|
-
name: redcarpet
|
144
|
-
requirement: !ruby/object:Gem::Requirement
|
145
|
-
none: false
|
146
|
-
requirements:
|
147
|
-
- - ! '>='
|
148
|
-
- !ruby/object:Gem::Version
|
149
|
-
version: '0'
|
150
|
-
type: :development
|
151
|
-
prerelease: false
|
152
|
-
version_requirements: !ruby/object:Gem::Requirement
|
153
|
-
none: false
|
154
|
-
requirements:
|
155
|
-
- - ! '>='
|
156
|
-
- !ruby/object:Gem::Version
|
157
|
-
version: '0'
|
158
|
-
- !ruby/object:Gem::Dependency
|
159
|
-
name: pry
|
160
|
-
requirement: !ruby/object:Gem::Requirement
|
161
|
-
none: false
|
162
|
-
requirements:
|
163
|
-
- - ! '>='
|
164
|
-
- !ruby/object:Gem::Version
|
165
|
-
version: '0'
|
166
|
-
type: :development
|
167
|
-
prerelease: false
|
168
|
-
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
none: false
|
170
|
-
requirements:
|
171
|
-
- - ! '>='
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: '0'
|
174
|
-
- !ruby/object:Gem::Dependency
|
175
|
-
name: rake
|
176
|
-
requirement: !ruby/object:Gem::Requirement
|
177
|
-
none: false
|
178
|
-
requirements:
|
179
|
-
- - ! '>='
|
180
|
-
- !ruby/object:Gem::Version
|
181
|
-
version: '0'
|
182
|
-
type: :development
|
183
|
-
prerelease: false
|
184
|
-
version_requirements: !ruby/object:Gem::Requirement
|
185
|
-
none: false
|
186
|
-
requirements:
|
187
|
-
- - ! '>='
|
188
|
-
- !ruby/object:Gem::Version
|
189
|
-
version: '0'
|
190
78
|
description: Compile Haml CoffeeScript templates in the Rails asset pipeline.
|
191
79
|
email:
|
192
80
|
- michi@netzpiraten.ch
|
@@ -194,16 +82,16 @@ executables: []
|
|
194
82
|
extensions: []
|
195
83
|
extra_rdoc_files: []
|
196
84
|
files:
|
197
|
-
- lib/haml_coffee_assets/
|
198
|
-
- lib/haml_coffee_assets/
|
199
|
-
- lib/haml_coffee_assets/
|
200
|
-
- lib/haml_coffee_assets/
|
85
|
+
- lib/haml_coffee_assets/compiler.rb
|
86
|
+
- lib/haml_coffee_assets/configuration.rb
|
87
|
+
- lib/haml_coffee_assets/rails/engine.rb
|
88
|
+
- lib/haml_coffee_assets/tilt/template_handler.rb
|
201
89
|
- lib/haml_coffee_assets/version.rb
|
202
90
|
- lib/haml_coffee_assets/version.rbc
|
203
91
|
- lib/haml_coffee_assets.rb
|
204
92
|
- lib/js/coffee-script.js
|
205
|
-
- lib/js/
|
206
|
-
- lib/
|
93
|
+
- lib/js/haml_coffee_assets.js
|
94
|
+
- lib/js/hamlcoffee.js
|
207
95
|
- vendor/assets/javascripts/hamlcoffee.js.coffee.erb
|
208
96
|
- LICENSE
|
209
97
|
- README.md
|
@@ -221,7 +109,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
221
109
|
version: '0'
|
222
110
|
segments:
|
223
111
|
- 0
|
224
|
-
hash: -
|
112
|
+
hash: -3525235316450724060
|
225
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
226
114
|
none: false
|
227
115
|
requirements:
|
@@ -1,64 +0,0 @@
|
|
1
|
-
# coding: UTF-8
|
2
|
-
|
3
|
-
module HamlCoffeeAssets
|
4
|
-
|
5
|
-
# Hook the Haml CoffeeScript template into a Rails app.
|
6
|
-
#
|
7
|
-
class Engine < Rails::Engine
|
8
|
-
|
9
|
-
config.hamlcoffee = ActiveSupport::OrderedOptions.new
|
10
|
-
|
11
|
-
DEFAULT_CONFIG = {
|
12
|
-
:format => 'html5',
|
13
|
-
:namespace => 'window.JST',
|
14
|
-
:uglify => false,
|
15
|
-
:basename => false,
|
16
|
-
:escapeHtml => true,
|
17
|
-
:escapeAttributes => true,
|
18
|
-
:cleanValue => true,
|
19
|
-
:customHtmlEscape => 'HAML.escape',
|
20
|
-
:customCleanValue => 'HAML.cleanValue',
|
21
|
-
:customPreserve => 'HAML.escape',
|
22
|
-
:customFindAndPreserve => 'HAML.findAndPreserve',
|
23
|
-
:customSurround => 'HAML.surround',
|
24
|
-
:customSucceed => 'HAML.succeed',
|
25
|
-
:customPrecede => 'HAML.precede',
|
26
|
-
:preserve => 'textarea,pre',
|
27
|
-
:autoclose => 'meta,img,link,br,hr,input,area,param,col,base',
|
28
|
-
:context => 'HAML.context'
|
29
|
-
}
|
30
|
-
|
31
|
-
# Initialize Haml Coffee Assets after Sprockets
|
32
|
-
#
|
33
|
-
initializer 'sprockets.hamlcoffeeassets', :group => :all, :after => 'sprockets.environment' do |app|
|
34
|
-
next unless app.assets
|
35
|
-
|
36
|
-
# Register tilt template
|
37
|
-
app.assets.register_engine '.hamlc', HamlCoffeeTemplate
|
38
|
-
|
39
|
-
# Set application configuration for the HAML templates.
|
40
|
-
options = DEFAULT_CONFIG.merge(app.config.hamlcoffee)
|
41
|
-
|
42
|
-
HamlCoffee.configure do |config|
|
43
|
-
config.namespace = options[:namespace]
|
44
|
-
config.format = options[:format]
|
45
|
-
config.uglify = options[:uglify]
|
46
|
-
config.basename = options[:basename]
|
47
|
-
config.escapeHtml = options[:escapeHtml]
|
48
|
-
config.escapeAttributes = options[:escapeAttributes]
|
49
|
-
config.cleanValue = options[:cleanValue]
|
50
|
-
config.customHtmlEscape = options[:customHtmlEscape]
|
51
|
-
config.customCleanValue = options[:customCleanValue]
|
52
|
-
config.customPreserve = options[:customPreserve]
|
53
|
-
config.customFindAndPreserve = options[:customFindAndPreserve]
|
54
|
-
config.customSurround = options[:customSurround]
|
55
|
-
config.customSucceed = options[:customSucceed]
|
56
|
-
config.customPrecede = options[:customPrecede]
|
57
|
-
config.preserveTags = options[:preserve]
|
58
|
-
config.selfCloseTags = options[:autoclose]
|
59
|
-
config.context = options[:context]
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
end
|
64
|
-
end
|