snabberb 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -0
- data/lib/snabberb/version.rb +1 -1
- data/lib/snabberb.rb +14 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d93f43d626c08cee99d8841191645c31e8d975401896b7f18ffee18c46ac459
|
4
|
+
data.tar.gz: 6f65115a69e13d77fccce6162c38f03f315d0c034e20e146af6c1acc3f5824b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b29014129127dc418951f000e0ddf47bd0a2985cd8c44cb8bada9b874c7a66d353db5ca6e6f18331b979fb3041a07a0b35dbaf3ef29bc8d667486f7e5d5ed7c7
|
7
|
+
data.tar.gz: 94cccfec82ed3572a3a718d8433ad031b291a977109747ffac5422731137cedc6a2d450e9506127330dcb4b1790bffc186aada5f0e2ca513b2957506ff2e5a3d
|
data/README.md
CHANGED
@@ -150,6 +150,14 @@ Snabberb.prerender_script('LayoutClass', 'ApplicationClass', 'application_id', j
|
|
150
150
|
|
151
151
|
A detailed example can be found [in the Roda example](examples/roda).
|
152
152
|
|
153
|
+
### Generating HTML from a File
|
154
|
+
|
155
|
+
You can generate HTML from a component with a file.
|
156
|
+
|
157
|
+
Snabberb.html('path/to/my\_component.rb', **needs)
|
158
|
+
|
159
|
+
This reads in the ruby file at the path and calls html on the CamelCased version of the file name.
|
160
|
+
|
153
161
|
## Installation
|
154
162
|
|
155
163
|
Add this line to your application's Gemfile:
|
data/lib/snabberb/version.rb
CHANGED
data/lib/snabberb.rb
CHANGED
@@ -18,7 +18,7 @@ module Snabberb
|
|
18
18
|
when nil
|
19
19
|
'Opal.nil'
|
20
20
|
else
|
21
|
-
wrap_s(obj)
|
21
|
+
wrap_s(obj.to_s)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -38,6 +38,19 @@ module Snabberb
|
|
38
38
|
"Opal.hash(#{args})"
|
39
39
|
end
|
40
40
|
|
41
|
+
# takes in a file and needs
|
42
|
+
# calls html on the CamelCased version of the file with the needs
|
43
|
+
def self.html(file, **needs)
|
44
|
+
klass = file.split('/').last
|
45
|
+
.split('.').first
|
46
|
+
.split('_').map(&:capitalize).join
|
47
|
+
|
48
|
+
<<~RUBY
|
49
|
+
#{File.read(file)}
|
50
|
+
#{klass}.html(`#{wrap(needs)}`)
|
51
|
+
RUBY
|
52
|
+
end
|
53
|
+
|
41
54
|
def self.prerender_script(layout, application, application_id, javascript_include_tags: '', **needs)
|
42
55
|
needs = wrap(needs)
|
43
56
|
attach_func = wrap_s("Opal.$$.#{application}.$attach(\"#{application_id}\", #{needs})")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: snabberb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toby Mao
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|