snabberb 0.4.0 → 0.4.1

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
  SHA256:
3
- metadata.gz: 5d93f43d626c08cee99d8841191645c31e8d975401896b7f18ffee18c46ac459
4
- data.tar.gz: 6f65115a69e13d77fccce6162c38f03f315d0c034e20e146af6c1acc3f5824b3
3
+ metadata.gz: 2eb7d55b5b19a6c6ffaa167950fbbf680820db02e48b822e8ff549ca8359ee1e
4
+ data.tar.gz: bed391d52d2fe3802a41a9f01852a6f3aaa204df2b2b5771a204860044d49910
5
5
  SHA512:
6
- metadata.gz: b29014129127dc418951f000e0ddf47bd0a2985cd8c44cb8bada9b874c7a66d353db5ca6e6f18331b979fb3041a07a0b35dbaf3ef29bc8d667486f7e5d5ed7c7
7
- data.tar.gz: 94cccfec82ed3572a3a718d8433ad031b291a977109747ffac5422731137cedc6a2d450e9506127330dcb4b1790bffc186aada5f0e2ca513b2957506ff2e5a3d
6
+ metadata.gz: 6078202977bcef2d48f546d53325d503f702a473d01374b7d322f08e0166fb57cd7eb01702cf4992078249e5c1ac70933a07ce67ed59515b6800e980581a31e7
7
+ data.tar.gz: a13532e40fd2f2bdeefebea9d6366ce5179b1254f9ccfe467368db89a5500fe47d2b3e7bca9cf9db3719f93c8c0892b2936e69408757cc6b061544015b856edf
data/README.md CHANGED
@@ -154,9 +154,9 @@ A detailed example can be found [in the Roda example](examples/roda).
154
154
 
155
155
  You can generate HTML from a component with a file.
156
156
 
157
- Snabberb.html('path/to/my\_component.rb', **needs)
157
+ Snabberb.html\_script('path/to/my\_component.rb', **needs)
158
158
 
159
- This reads in the ruby file at the path and calls html on the CamelCased version of the file name.
159
+ This reads in the ruby file at the path and generates javascript that calls html on the CamelCased version of the file name.
160
160
 
161
161
  ## Installation
162
162
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Snabberb
4
- VERSION = '0.4.0'
4
+ VERSION = '0.4.1'
5
5
  end
data/lib/snabberb.rb CHANGED
@@ -40,15 +40,17 @@ module Snabberb
40
40
 
41
41
  # takes in a file and needs
42
42
  # calls html on the CamelCased version of the file with the needs
43
- def self.html(file, **needs)
43
+ def self.html_script(file, **needs)
44
44
  klass = file.split('/').last
45
45
  .split('.').first
46
46
  .split('_').map(&:capitalize).join
47
47
 
48
- <<~RUBY
48
+ script = <<~RUBY
49
49
  #{File.read(file)}
50
50
  #{klass}.html(`#{wrap(needs)}`)
51
51
  RUBY
52
+
53
+ Opal.compile(script).strip.chomp(';')
52
54
  end
53
55
 
54
56
  def self.prerender_script(layout, application, application_id, javascript_include_tags: '', **needs)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snabberb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toby Mao