without-rails 1.2.1 → 1.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 58fbae34e1610b713e5311b29cb495f04e9d43d3
4
- data.tar.gz: 7d036d29029167bd2fd8526c98c6ebb88babb986
3
+ metadata.gz: 53e7aa0b5f38d84a04b935895212945890261c7b
4
+ data.tar.gz: 611a769e68d1463ff373e337ee6b2106226393b1
5
5
  SHA512:
6
- metadata.gz: 93f14933f50efa66779a8a42002640668041f45346b2b0c47e5a98a62f3b9f1037288086ec6feb3f0ba5e644580257f6e0641502e9663f690c2994a5ad4eb17c
7
- data.tar.gz: 56ad07b62f9ee151d4251e91475323a2871ca74b711370a984f5fd978f129c0e95f553e27a3a525606bd416f600d26627c454dc540bbb8b492d3de88e69738ee
6
+ metadata.gz: 901b22fc905abc63b0b5e4f1e8364abf08bd9ac2b489352d47b1b83e30724ce9ab44d15de2bc94f43d4c16d07877ec32bd9b310164356134ced99225be602d5c
7
+ data.tar.gz: ff63c6c55f078eee6be88a06ff14e2ffd7cca260d8824b29736fab939cad5f94f90cf96fa600f93fb4da964025c5f87297424424c1e4fbb7d1510618e3315104
@@ -1,5 +1,5 @@
1
1
  module Without
2
2
  module Rails
3
- VERSION = "1.2.1"
3
+ VERSION = "1.2.2"
4
4
  end
5
5
  end
@@ -1,21 +1,20 @@
1
1
  //
2
- // without.js v1.2.1: Yet another CoffeScript template (without `with`, coffescript and templates)
2
+ // without.js v1.2.2: Yet another CoffeScript template (without `with`, coffescript and templates)
3
3
  // https://github.com/ukoloff/without
4
4
  //
5
5
  !function(){
6
+ var emptyTags = {}
6
7
  function adhocTag()
7
8
  {
8
- return function(name, empty) { return tag(name, empty) }
9
- function isEmpty(name)
10
- {
11
- for(var i = eTags.length - 1; i >= 0; i--)
12
- if(name == eTags[i])
13
- return true
14
- }
9
+ return Tag
10
+ function Tag(name, empty) { return tag(name, empty) }
15
11
  function tag(name, empty)
16
12
  {
17
- if(null==empty)
18
- empty = isEmpty(String(name).toLowerCase())
13
+ if(null == empty)
14
+ {
15
+ makeScope()
16
+ empty = emptyTags[('' + name).toLowerCase()]
17
+ }
19
18
  return makeTag(name, empty)
20
19
  }
21
20
  }
@@ -35,13 +34,14 @@ function coffeeScript(a)
35
34
  {
36
35
  if(1 != a.length || 'function' != typeof a[0])
37
36
  throw SyntaxError('Usage: coffeescript -> code')
38
- html += '<script><!--\n(' + a[0].toString() + ')()\n//-->\n</'
37
+ html += '<script><!--\n(' + a[0] + ')()\n//-->\n</'
39
38
  html += 'script>'
40
39
  }
41
40
  function makeComment()
42
41
  {
43
42
  var level = 0
44
- return function() { comment(arguments) }
43
+ return Comment
44
+ function Comment() { comment(arguments) }
45
45
  function comment(a)
46
46
  {
47
47
  html += level++ ? '<comment level="' + level + '">' : "<!-- "
@@ -51,7 +51,8 @@ function makeComment()
51
51
  }
52
52
  function compile()
53
53
  {
54
- return function withOut(fn)
54
+ return withOut
55
+ function withOut(fn)
55
56
  {
56
57
  return compile(fn)
57
58
  }
@@ -85,7 +86,7 @@ function flatten(array)
85
86
  var htmlEntities = {'&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;'}
86
87
  function h(s)
87
88
  {
88
- return String(s).replace(/[&<>"]/g, function(e) { return htmlEntities[e] })
89
+ return ('' + s).replace(/[&<>"]/g, function(e) { return htmlEntities[e] })
89
90
  }
90
91
  function JSTs()
91
92
  {
@@ -116,7 +117,7 @@ function JST$(a)
116
117
  Ts[i] = renderable(v, template, i + 1)
117
118
  }
118
119
  template.id = id
119
- fetchJSTs = function() {}
120
+ fetchJSTs = nop
120
121
  }
121
122
  }
122
123
  function filterLocals(locals)
@@ -152,7 +153,8 @@ function $compile(fn)
152
153
  }
153
154
  function makeTag(name, empty)
154
155
  {
155
- return function() { tag(arguments) }
156
+ return Tag
157
+ function Tag() { tag(arguments) }
156
158
  function attr(k, v)
157
159
  {
158
160
  if(null == v || false === v) return
@@ -216,6 +218,9 @@ function merge()
216
218
  }
217
219
  return res
218
220
  }
221
+ function nop()
222
+ {
223
+ }
219
224
  function noTag(a)
220
225
  {
221
226
  children('object' == typeof a[0] ? shift(a) : a)
@@ -269,7 +274,7 @@ function renderable(fn, template, n)
269
274
  var name = template.id
270
275
  if(null == name)
271
276
  name = ''
272
- name = String(name).split(/\W+/).join('/').replace(/^\/+|\/+$/g, '')
277
+ name = ('' + name).split(/\W+/).join('/').replace(/^\/+|\/+$/g, '')
273
278
  if(!name.length)
274
279
  name = ++names
275
280
  template.id = name
@@ -279,7 +284,7 @@ function renderable(fn, template, n)
279
284
  }
280
285
  function build()
281
286
  {
282
- var name, code = fn.toString()
287
+ var name, code = '' + fn
283
288
  minified = !/[\r\n]/.test(code)
284
289
  makeScope()
285
290
  var myScope = merge(scope, filterLocals(withOut.$), filterLocals(template.$))
@@ -287,7 +292,7 @@ function renderable(fn, template, n)
287
292
  if(!minified)
288
293
  code += '\n//# sourceURL=eval://withOut/' + (name = getName()) + '.wo'
289
294
  fn = (new Function(code)).call(myScope)
290
- build = function() {}
295
+ build = nop
291
296
  if(minified)
292
297
  return
293
298
  fn.displayName = '<' + name + '>'
@@ -307,42 +312,56 @@ function renderable(fn, template, n)
307
312
  var scope
308
313
  function makeScope()
309
314
  {
310
- makeScope = function() {}
315
+ makeScope = nop
311
316
  scope = {
312
317
  print: text,
313
318
  text: text,
314
319
  raw: function() { raw(arguments) },
315
320
  notag: function() { noTag(arguments) },
316
321
  coffeescript: function() { coffeeScript(arguments) },
317
- blackhole: function() {},
322
+ blackhole: nop,
318
323
  comment: makeComment(),
319
324
  tag: adhocTag(),
320
325
  $var: makeTag('var')
321
326
  }
322
- for(var i = nTags.length - 1; i >= 0; i--)
323
- scope[nTags[i]] = makeTag(nTags[i])
324
- for(var i = eTags.length - 1; i >= 0; i--)
325
- scope[eTags[i]] = makeTag(eTags[i], true)
327
+ var tag, tags
328
+ split(nTags)
329
+ while(tag = tags.pop())
330
+ scope[tag] = makeTag(tag)
331
+ split(eTags)
332
+ while(tag = tags.pop())
333
+ {
334
+ scope[tag] = makeTag(tag, 1)
335
+ emptyTags[tag] = 1
336
+ }
337
+ function split(fn)
338
+ {
339
+ tags = fn().split(' ')
340
+ }
326
341
  }
327
342
  var slice = [].slice
328
343
  function shift(a)
329
344
  {
330
345
  return slice.call(a, 1)
331
346
  }
332
- function split(s)
347
+ function nTags()
348
+ {
349
+ nTags = nop
350
+ var s = 'a abbr acronym address applet article aside audio '
351
+ s += 'b bdo big blockquote body button canvas caption center cite code colgroup command '
352
+ s += 'datalist dd del details dfn dir div dl dt em embed '
353
+ s += 'fieldset figcaption figure font footer form frameset '
354
+ s += 'h1 h2 h3 h4 h5 h6 head header hgroup html i iframe ins keygen kbd '
355
+ s += 'label legend li map mark menu meter nav noframes noscript '
356
+ s += 'object ol optgroup option output p pre progress q rp rt ruby '
357
+ s += 's samp script section select small source span strike strong style sub summary sup '
358
+ return s + 'table tbody td textarea tfoot th thead time title tr tt u ul video wbr xmp'
359
+ }
360
+ function eTags()
333
361
  {
334
- return s.split(' ')
362
+ eTags = nop
363
+ return 'area base basefont br col frame hr img input link meta param'
335
364
  }
336
- var nTags = split('a abbr acronym address applet article aside audio ' +
337
- 'b bdo big blockquote body button canvas caption center cite code colgroup command ' +
338
- 'datalist dd del details dfn dir div dl dt em embed ' +
339
- 'fieldset figcaption figure font footer form frameset ' +
340
- 'h1 h2 h3 h4 h5 h6 head header hgroup html i iframe ins keygen kbd ' +
341
- 'label legend li map mark menu meter nav noframes noscript ' +
342
- 'object ol optgroup option output p pre progress q rp rt ruby ' +
343
- 's samp script section select small source span strike strong style sub summary sup ' +
344
- 'table tbody td textarea tfoot th thead time title tr tt u ul video wbr xmp')
345
- var eTags = split('area base basefont br col frame hr img input link meta param')
346
365
  function text()
347
366
  {
348
367
  print(arguments)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: without-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stas Ukolov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-03 00:00:00.000000000 Z
11
+ date: 2017-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties