smolbars 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f624459b6448042adad2e8b0adb09948f23de085136137624b15925b926b14e0
4
- data.tar.gz: 0bd1001f25af33c61959e74ead28bb19bd3e3794c4d0809d0906903ac29567b0
3
+ metadata.gz: 40d10c7406cd516218824c76f8a4fac9ba3c6caaa7002b30519943d64adc6857
4
+ data.tar.gz: 0d27753a31290273c8174e3d5e4270f50a819bd00d03c6d0d75785f4efa9c424
5
5
  SHA512:
6
- metadata.gz: efe29c440d8a973c2b9b482e443b7fc9fcf1615913aaed974606b24e6b53ba1c3eb788c8df22ae1313ee7958c700008754c1fd7615d3d4a64494a624f730774d
7
- data.tar.gz: 5c6e1be44b56bee693438230f4a07bb1808749dcd6589599c95336164ab9c5b33a55d5e022b44b14dcda85a227acaae7c186145d3d2e1b46460c64d2be75dea2
6
+ metadata.gz: fa466da75da4abe7376b214290c873e07702cacc398636742c2e5db8aec1bfbeab68b3af0a24ea13e40d5a122671b8601ee3550ac9da9cfbae221d78717c8015
7
+ data.tar.gz: 42d12dbd05de3d84757e5553b43dc651c15e13a5f4144e74d5694bab388201e61ec1546b85e57d074fd8cf6bf4a193e69939d40d789c16725ba650a1d545ad94
@@ -5,19 +5,16 @@ require 'securerandom'
5
5
  module Smolbars
6
6
  class Context
7
7
  def initialize(**kwargs)
8
- @@snapshot ||= MiniRacer::Snapshot.new(File.read(Handlebars::Source.bundled_path))
9
- @js = MiniRacer::Context.new(kwargs.merge(snapshot: @@snapshot))
8
+ @js = MiniRacer::Context.new(kwargs)
9
+ @js.load(Handlebars::Source.bundled_path)
10
10
  end
11
11
 
12
12
  # Note that this is a hacky JS expression builder. We cannot pass JS AST in to mini_racer so we have to
13
13
  # hope the template passed in does not form invalid Ruby. So don't use templates with backtick characters without
14
14
  # manually escaping them
15
15
  def compile(template)
16
- if template.include?("`")
17
- raise RuntimeError.new("template cannot contain a backtick character '`'")
18
- end
19
16
  handle = fn_handle
20
- invocation = %Q{var #{handle} = Handlebars.compile(`#{template}`);}
17
+ invocation = %Q{var #{handle} = Handlebars.compile(`#{template.gsub('`', "\`")}`);}
21
18
  @js.eval(invocation)
22
19
  ::Smolbars::Template.new(self, handle)
23
20
  end
@@ -1,3 +1,3 @@
1
1
  module Smolbars
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smolbars
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Lowell
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-02-16 00:00:00.000000000 Z
12
+ date: 2022-04-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mini_racer
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  - !ruby/object:Gem::Version
99
99
  version: '0'
100
100
  requirements: []
101
- rubygems_version: 3.3.7
101
+ rubygems_version: 3.2.22
102
102
  signing_key:
103
103
  specification_version: 4
104
104
  summary: Ruby bindings for the smolbars.js templating library