riot_js-rails 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/riot_js/rails/processors/renderer.rb +38 -0
- data/lib/riot_js/rails/version.rb +1 -1
- data/vendor/assets/javascripts/riot.js +15 -11
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d04e52981c0b23629682d271c8eeff74e501551d
|
4
|
+
data.tar.gz: d2190c61c536e85c32a24a5c80e378687eaa0eee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1d9ab022d4dc8f462567f80d7b65b8ca1357bf3276cbb0705727ad124f05befd500739b17d4ca75740ce1c8991a619bd77ee53b260f4b0f0db20f27a628e908
|
7
|
+
data.tar.gz: e0af3d66269f60a0bf42b1e36ee6d90d1b177e02ab46418d3214f5f5f3fa4b745b5730f2809964fa60641c7d1d2ba8377ffa2d39d2896239adb022f22ffd963b
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'action_view'
|
2
|
+
require 'execjs'
|
3
|
+
|
4
|
+
module RiotJs
|
5
|
+
module Rails
|
6
|
+
class Renderer
|
7
|
+
include ::ActionView::Helpers::JavaScriptHelper
|
8
|
+
|
9
|
+
JS_RUNTIME = ::ExecJS::ExternalRuntime.new(
|
10
|
+
name: 'Node.js (V8)',
|
11
|
+
command: ['nodejs', 'node'],
|
12
|
+
encoding: 'UTF-8',
|
13
|
+
runner_path: File.expand_path('../../../../../vendor/assets/javascripts/compiler/node_runner.js', __FILE__),
|
14
|
+
)
|
15
|
+
JS_RUNTIME.instance_variable_set :@binary, JS_RUNTIME.send(:locate_binary) if defined?(::Barista)
|
16
|
+
|
17
|
+
RIOT_COMPILER_PATH = File.expand_path('../../../../../vendor/assets/javascripts/compiler/compiler.js', __FILE__)
|
18
|
+
|
19
|
+
def self.instance
|
20
|
+
@@instance ||= new
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.compile(tag_source)
|
24
|
+
instance.compile(tag_source)
|
25
|
+
end
|
26
|
+
|
27
|
+
def compile(tag_source)
|
28
|
+
compiler_source = <<-JS
|
29
|
+
var compiler = require("#{RIOT_COMPILER_PATH}");
|
30
|
+
return compiler.compile("#{escape_javascript(tag_source)}");
|
31
|
+
JS
|
32
|
+
|
33
|
+
JS_RUNTIME.exec(compiler_source)
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
/* Riot v2.
|
1
|
+
/* Riot v2.5.0, @license MIT */
|
2
2
|
|
3
3
|
;(function(window, undefined) {
|
4
4
|
'use strict';
|
5
|
-
var riot = { version: 'v2.
|
5
|
+
var riot = { version: 'v2.5.0', settings: {} },
|
6
6
|
// be aware, internal usage
|
7
7
|
// ATTENTION: prefix the global dynamic variables with `__`
|
8
8
|
|
@@ -1286,8 +1286,8 @@ function _each(dom, parent, expr) {
|
|
1286
1286
|
unmountRedundant(items, tags)
|
1287
1287
|
|
1288
1288
|
// insert the new nodes
|
1289
|
+
root.insertBefore(frag, ref)
|
1289
1290
|
if (isOption) {
|
1290
|
-
root.appendChild(frag)
|
1291
1291
|
|
1292
1292
|
// #1374 FireFox bug in <option selected={expression}>
|
1293
1293
|
if (FIREFOX && !root.multiple) {
|
@@ -1300,7 +1300,6 @@ function _each(dom, parent, expr) {
|
|
1300
1300
|
}
|
1301
1301
|
}
|
1302
1302
|
}
|
1303
|
-
else root.insertBefore(frag, ref)
|
1304
1303
|
|
1305
1304
|
// set the 'tags' property of the parent tag
|
1306
1305
|
// if child is 'undefined' it means that we don't need to set this property
|
@@ -1558,7 +1557,9 @@ function Tag(impl, conf, innerHTML) {
|
|
1558
1557
|
|
1559
1558
|
defineProperty(this, 'mixin', function() {
|
1560
1559
|
each(arguments, function(mix) {
|
1561
|
-
var instance
|
1560
|
+
var instance,
|
1561
|
+
props = [],
|
1562
|
+
obj
|
1562
1563
|
|
1563
1564
|
mix = typeof mix === T_STRING ? riot.mixin(mix) : mix
|
1564
1565
|
|
@@ -1566,17 +1567,20 @@ function Tag(impl, conf, innerHTML) {
|
|
1566
1567
|
if (isFunction(mix)) {
|
1567
1568
|
// create the new mixin instance
|
1568
1569
|
instance = new mix()
|
1569
|
-
// save the prototype to loop it afterwards
|
1570
|
-
mix = mix.prototype
|
1571
1570
|
} else instance = mix
|
1572
1571
|
|
1572
|
+
// build multilevel prototype inheritance chain property list
|
1573
|
+
do props = props.concat(Object.getOwnPropertyNames(obj || instance))
|
1574
|
+
while (obj = Object.getPrototypeOf(obj || instance))
|
1575
|
+
|
1573
1576
|
// loop the keys in the function prototype or the all object keys
|
1574
|
-
each(
|
1577
|
+
each(props, function(key) {
|
1575
1578
|
// bind methods to self
|
1576
|
-
if (key != 'init')
|
1579
|
+
if (key != 'init' && !self[key])
|
1580
|
+
// apply method only if it does not already exist on the instance
|
1577
1581
|
self[key] = isFunction(instance[key]) ?
|
1578
|
-
|
1579
|
-
|
1582
|
+
instance[key].bind(self) :
|
1583
|
+
instance[key]
|
1580
1584
|
})
|
1581
1585
|
|
1582
1586
|
// init method will be called automatically
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riot_js-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bartosz Jaroszewski
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -130,6 +130,7 @@ files:
|
|
130
130
|
- lib/riot_js/rails/helper.rb
|
131
131
|
- lib/riot_js/rails/processors/compiler.rb
|
132
132
|
- lib/riot_js/rails/processors/processor.rb
|
133
|
+
- lib/riot_js/rails/processors/renderer.rb
|
133
134
|
- lib/riot_js/rails/processors/sprockets_processor_v2.rb
|
134
135
|
- lib/riot_js/rails/processors/sprockets_processor_v3.rb
|
135
136
|
- lib/riot_js/rails/railtie.rb
|
@@ -166,3 +167,4 @@ signing_key:
|
|
166
167
|
specification_version: 4
|
167
168
|
summary: Muut Riot integration with Rails.
|
168
169
|
test_files: []
|
170
|
+
has_rdoc:
|