without-rails 1.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a2537301a97a3750472cf4011e483bbaa7a6eef0
4
+ data.tar.gz: b7cab434a2ce7732729f850c771cf1902205c7c0
5
+ SHA512:
6
+ metadata.gz: b2d98906136da8fcacf15ad20ea359a87d815c8482592c7f1f915a558aa66c7fadaa64eac7793e7e1a2b0295d051830c7885052f62a7888894df26a3258e530b
7
+ data.tar.gz: e8a28d873f619e257bb6f034f1b97d0a2b58bd1de73fde29a1eccb5312c4e041024805c4c4897f66dd2bbb1e6cd6dcb62db6eb90d298c617ad3b1df832d1aebb
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in without-rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Stas Ukolov
2
+
3
+ MIT License
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
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # Without::Rails
2
+
3
+ without-rails wraps [withOut](https://github.com/ukoloff/without)
4
+ template engine for simple use with rails asset pipeline.
5
+ The gem includes the development (non-minified) source
6
+ for ease of exploration.
7
+ The asset pipeline will minify in production.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'without-rails'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install without-rails
22
+
23
+ ## Usage
24
+
25
+ Add the following directive to your Javascript manifest file
26
+ (application.js):
27
+
28
+
29
+ ```js
30
+ //= require without
31
+ ```
32
+
33
+ or to some .coffee file:
34
+
35
+
36
+ ```coffee
37
+ #= require without
38
+ ```
39
+
40
+ Later, inside any .coffee you can:
41
+
42
+ ```coffee
43
+ t = withOut.$compile ->
44
+ div id: @
45
+
46
+ $('#test').html t 'me'
47
+
48
+ ```
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,5 @@
1
+ module Without
2
+ module Rails
3
+ VERSION = "1.1.0"
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ require "without/rails/version"
2
+
3
+ module Without
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,285 @@
1
+ //
2
+ // without.js - CoffeScript template engine with lexical scoping
3
+ //
4
+
5
+ (function()
6
+ {
7
+ var
8
+ nTags='a abbr acronym address applet article aside audio b bdo big blockquote body button \
9
+ canvas caption center cite code colgroup command datalist dd del details dfn dir div dl dt \
10
+ em embed fieldset figcaption figure font footer form frameset h1 h2 h3 h4 h5 h6 head header hgroup html \
11
+ i iframe ins keygen kbd label legend li map mark menu meter nav noframes noscript object \
12
+ ol optgroup option output p pre progress q rp rt ruby \
13
+ s samp script section select small source span strike strong style sub summary sup \
14
+ table tbody td textarea tfoot th thead time title tr tt u ul video wbr xmp'.split(' '),
15
+ eTags='area base basefont br col frame hr img input link meta param'.split(' '),
16
+ htmlEntities={'&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;'},
17
+ slice=[].slice,
18
+ scope={},
19
+ names=0,
20
+ html='',
21
+ _this
22
+
23
+ function h(s)
24
+ {
25
+ return String(s).replace(/[&<>"]/g, function(e){return htmlEntities[e]})
26
+ }
27
+
28
+ function children(a)
29
+ {
30
+ var i, e
31
+ for(i=0; i<a.length; i++)
32
+ {
33
+ if(null==(e=a[i])) continue;
34
+ if('function'==typeof e)
35
+ e.call(_this)
36
+ else
37
+ html+=h(e)
38
+ }
39
+ }
40
+
41
+ function print(a)
42
+ {
43
+ var i, e
44
+ for(i=0; i<a.length; i++) if(null!=(e=a[i])) html+=h(e)
45
+ }
46
+
47
+ function raw(a)
48
+ {
49
+ var i, e
50
+ for(i=0; i<a.length; i++) if(null!=(e=a[i])) html+=e
51
+ }
52
+
53
+ function makeTag(name, empty)
54
+ {
55
+ return function(){tag(arguments)}
56
+ function attr(k, v)
57
+ {
58
+ if(null==v || false===v) return
59
+ html+=' '+h(k)
60
+ if(true!==v) html+='="'+h(v)+'"'
61
+ }
62
+ function nest(prefix, obj)
63
+ {
64
+ for(var k in obj)
65
+ if('object'==typeof obj[k])
66
+ nest(prefix+k+'-', obj[k])
67
+ else
68
+ attr(prefix+k, obj[k])
69
+ }
70
+ function tag(a)
71
+ {
72
+ html+='<'+name
73
+ var at=a[0]
74
+ if('object'==typeof at)
75
+ {
76
+ for(var k in at)
77
+ if('data'==k && 'object'==typeof at[k])
78
+ nest('data-', at[k])
79
+ else
80
+ attr(k, at[k])
81
+ a=slice.call(a, 1)
82
+ }
83
+ html+='>'
84
+ if(empty && a.length) throw new SyntaxError("<"+name+"> must have no content!")
85
+ if(empty) return
86
+ children(a)
87
+ html+="</"+name+">"
88
+ }
89
+ }
90
+
91
+ function makeComment()
92
+ {
93
+ var level=0;
94
+ return function(){ comment.apply(this, arguments) }
95
+ function comment()
96
+ {
97
+ html+= level++? '<comment level="'+level+'">' : "<!-- "
98
+ children(arguments)
99
+ html+= --level? '</comment>': ' -->'
100
+ }
101
+ }
102
+
103
+ function coffeeScript()
104
+ {
105
+ if(1!=arguments.length ||'function'!=typeof arguments[0])
106
+ throw new SyntaxError('Usage: coffeescript -> code')
107
+ html+='<script><!--\n('+arguments[0].toString()+')()\n//-->\n</script>';
108
+ }
109
+
110
+ function adhocTag()
111
+ {
112
+ return function(name, empty){ return tag(name, empty) }
113
+ function isEmpty(name)
114
+ {
115
+ for(var i in eTags) if(name==eTags[i]) return true
116
+ }
117
+ function tag(name, empty)
118
+ {
119
+ return makeTag(name, null==empty? isEmpty(String(name).toLowerCase()) : empty)
120
+ }
121
+ }
122
+
123
+ function noTag(attrs)
124
+ {
125
+ children('object'==typeof attrs ? slice.call(arguments, 1) : arguments)
126
+ }
127
+
128
+ scope.print=scope.text=function(){print(arguments)}
129
+ scope.raw=function(){raw(arguments)}
130
+ scope.tag=adhocTag()
131
+ scope.notag=function(){noTag.apply(this, arguments)}
132
+ scope.comment=makeComment()
133
+ scope.blackhole=function(){}
134
+ scope.coffeescript=function(){ coffeeScript.apply(this, arguments) }
135
+
136
+ for(var i in nTags) scope[nTags[i]]=makeTag(nTags[i])
137
+ scope.$var=makeTag('var')
138
+ for(var i in eTags) scope[eTags[i]]=makeTag(eTags[i], true)
139
+
140
+ function makeVars()
141
+ {
142
+ var v=[];
143
+ for(var tag in scope) v.push(tag+'=this.'+tag)
144
+ return 'var '+v.join(',')
145
+ }
146
+
147
+ function renderable(fn, wrapper, n)
148
+ {
149
+ if('function'!=typeof fn)
150
+ throw new TypeError("Call: withOut.compile(function)")
151
+ var pending=true, minified
152
+ wrapper.id=null
153
+ return render
154
+
155
+ function render()
156
+ {
157
+ if(pending) build()
158
+ try
159
+ {
160
+ var that=_this, x=html
161
+ _this=this
162
+ html=''
163
+ if(bp())
164
+ debugger // Hit `Step Into` (F11) twice
165
+ fn.apply(this, arguments)
166
+ return html
167
+ }
168
+ finally
169
+ {
170
+ _this=that
171
+ html=x
172
+ }
173
+ }
174
+
175
+ function getName()
176
+ {
177
+ var name = wrapper.id
178
+ if(null==name) name=''
179
+ name=String(name).split(/\W+/).join('/').replace(/^\/+|\/+$/g, '')
180
+ if(!name.length)name=++names
181
+ wrapper.id=name
182
+ if(n)
183
+ name+='['+n+']'
184
+ return name
185
+ }
186
+
187
+ function build()
188
+ {
189
+ var name
190
+ fn=fn.toString()
191
+ minified = !/[\r\n]/.test(fn)
192
+ fn=makeVars()+'\nreturn '+fn
193
+ if(!minified)
194
+ fn+='\n//# sourceURL=eval://withOut/'+(name=getName())+'.wo'
195
+ fn=(new Function(fn)).call(scope)
196
+ if(!minified)
197
+ {
198
+ fn.displayName='<'+name+'>'
199
+ wrapper.displayName='{{'+name+'}}'
200
+ }
201
+ }
202
+
203
+ function bp()
204
+ {
205
+ if(minified || false===lib.bp) return
206
+ if(lib.bp) return true
207
+ if(n && 'number'==typeof wrapper.bp)
208
+ return n==wrapper.bp
209
+ return wrapper.bp
210
+ }
211
+ }
212
+
213
+ function compile(fn)
214
+ {
215
+ var withOut=renderable(fn, wrapper)
216
+ return wrapper
217
+
218
+ function wrapper(){return withOut.apply(this, arguments)}
219
+ }
220
+
221
+ function $compile(fn)
222
+ {
223
+ var withOut=renderable(fn, wrapper)
224
+ return wrapper
225
+
226
+ function wrapper(that){return withOut.apply(that, arguments)}
227
+ }
228
+
229
+ function flatten(array)
230
+ {
231
+ var v, r=[]
232
+ for(var i in array)
233
+ if('object'==typeof(v=array[i]))
234
+ r.push.apply(r, flatten(v))
235
+ else
236
+ r.push(v)
237
+ return r
238
+ }
239
+
240
+ function JSTs(path)
241
+ {
242
+ var bound, Ts=flatten(slice.call(arguments))
243
+ wrapper.id=null
244
+ return wrapper
245
+
246
+ function wrapper(that){return JSTs.apply(that, arguments)}
247
+
248
+ function JSTs()
249
+ {
250
+ var S=''
251
+ if(!bound) fetchJSTs()
252
+ for(var i in Ts) S+=Ts[i].apply(this, arguments)
253
+ return S
254
+ }
255
+
256
+ function fetchJSTs()
257
+ {
258
+ var v, id=wrapper.id
259
+ for(var i in Ts)
260
+ {
261
+ if('function'!=typeof(v=Ts[i]) &&
262
+ 'function'!=typeof(v=JST[v]))
263
+ throw new Error("JST['"+Ts[i]+"'] not found or incorrect!")
264
+ Ts[i]=renderable(v, wrapper, Number(i)+1)
265
+ }
266
+ wrapper.id=id
267
+ bound=true
268
+ }
269
+ }
270
+
271
+ var lib={
272
+ compile: compile,
273
+ renderable: compile,
274
+ $compile: $compile,
275
+ JSTs: JSTs
276
+ }
277
+ if('undefined'!=typeof module && module.exports)
278
+ module.exports=lib
279
+ else if('function'==typeof define && define.amd)
280
+ define(lib)
281
+ else
282
+ this.withOut=lib
283
+ })()
284
+
285
+ //--[EOF]------------------------------------------------------------
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'without/rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "without-rails"
8
+ spec.version = Without::Rails::VERSION
9
+ spec.authors = ["Stas Ukolov"]
10
+ spec.email = ["ukoloff@gmail.com"]
11
+ spec.description = "Use withOut with Rails"
12
+ spec.summary = "This gem provides withOut template engine for Rails application"
13
+ spec.homepage = "https://github.com/ukoloff/without-rails"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.require_paths = ["lib"]
18
+
19
+ spec.add_dependency "railties"
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: without-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Stas Ukolov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: railties
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Use withOut with Rails
56
+ email:
57
+ - ukoloff@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - .gitignore
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - lib/without/rails.rb
68
+ - lib/without/rails/version.rb
69
+ - vendor/assets/javascripts/without.js
70
+ - without-rails.gemspec
71
+ homepage: https://github.com/ukoloff/without-rails
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project:
91
+ rubygems_version: 2.0.3
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: This gem provides withOut template engine for Rails application
95
+ test_files: []