smolbars 0.1.1 → 0.1.4

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: 60ba4fc490e6ea38e725fe7ba31791e14d024bf5e78387aab1f05ca6b2353f29
4
- data.tar.gz: 1bf4b383ca1687c1f850734811b829b30477396efa768634a238eabd2dc8fcc5
3
+ metadata.gz: 40d10c7406cd516218824c76f8a4fac9ba3c6caaa7002b30519943d64adc6857
4
+ data.tar.gz: 0d27753a31290273c8174e3d5e4270f50a819bd00d03c6d0d75785f4efa9c424
5
5
  SHA512:
6
- metadata.gz: b15063c4bc1c09ef3f8cdeeb604bf992042b8a0b86180fa3c7513f8a2e435fc74eca8e731d9fc440bf1c64e256db7c1e6bc0e456d841c1ab003d5957b5c98eb1
7
- data.tar.gz: e628f36f4b0e29c288467ea25c1e4cb0a3a7a92ae9abb4d315c7c7acde496f0fd9124afa01ccffbd77903498e02721eb6e88353edccf1afcc65e69acfee4676a
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
@@ -8,8 +8,7 @@ module Smolbars
8
8
  if args.length == 0
9
9
  invocation = "%s(%s)" % [@fn, kwargs.to_json]
10
10
  else
11
- raise "unsupported"
12
- invocation = "%s(%s)" % [@fn, args.to_json]
11
+ invocation = "%s(%s)" % [@fn, args.first.to_json]
13
12
  end
14
13
  @context.eval(invocation)
15
14
  end
@@ -1,3 +1,3 @@
1
1
  module Smolbars
2
- VERSION = "0.1.1"
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.1
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-11 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