mvz-ruby-handlebars 0.0.11 → 0.0.12

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: 8e028cfa3a1917825d23736af3ede7aa5cc5c73ab48e2b7b615053007f7fc706
4
- data.tar.gz: 041f11d9b9d907960742c200aa2c659719517087842febc9a63a0664c5fc2a84
3
+ metadata.gz: d971e4df297aebaa8445decfe5756ffc6140318c8ad93d13ca90c3a2ed8d6601
4
+ data.tar.gz: 47de3f30733f85f377bfd5e3dc2b554940f406e96066de3fb38c1a53c8faf207
5
5
  SHA512:
6
- metadata.gz: 02dd28bba4ee51f0d3f676777b9a596e2c9ea360ca3062ed301cacba5af69c74772b5780a106b5d2d5fa59362ac07b4ae6326ab20646e4a0f544faff31762210
7
- data.tar.gz: aba3272df76c517819971f04d9ad5259d9d5b7459059840310672d8ed660ef5849a6ac3bed844974c6a41760d740d5a628c9bad5f499455da87ecdd0131f3469
6
+ metadata.gz: 21bf66dedf5b10f50f46421ebfc632853b38cb3836f5fd4f4c1a798359b0cc3dba057fc8aa3f0b8dd329c5c862d8a78e27c92dcc8313d9873c5c5a506a383863
7
+ data.tar.gz: 3abb82f084a654f633f928535bb8f6331d066269ae14619a645b88fb50c7c0f395065201046600ca3fdc81a0a9e31f0b51da1909243d5719b4e964186b0bb376
data/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ This is the changelog for mvz-ruby-handlebars
4
+
5
+ ## 0.0.12 (2024-05-18)
6
+
7
+ * Support Ruby 3.0 through 3.3, dropping support for 2.6 and 2.7
8
+ ([#25] and [#30] by [mvz])
9
+ * Pull in upstream master. See below for the included changes ([#32] by [mvz])
10
+ * Handle single open-close curly pair ([#34] by [mvz])
11
+ * Speed up template content detection ([#35] by [mvz])
12
+ * Speed up opening and closing curly recognition ([#36] by [mvz])
13
+
14
+ [mvz]: https://github.com/mvz
15
+ [#25]: https://github.com/mvz/ruby-handlebars/pull/25
16
+ [#30]: https://github.com/mvz/ruby-handlebars/pull/30
17
+ [#32]: https://github.com/mvz/ruby-handlebars/pull/32
18
+ [#34]: https://github.com/mvz/ruby-handlebars/pull/34
19
+ [#35]: https://github.com/mvz/ruby-handlebars/pull/35
20
+ [#36]: https://github.com/mvz/ruby-handlebars/pull/36
21
+
22
+ ### [ruby-handlebars 0.4.1] (2022/06/01)
23
+
24
+ - bump dependencies
25
+ - move CI to GitHub actions
26
+
27
+ The remaining changes from this release were already included in mvz-ruby-handlebars 0.0.10
28
+
3
29
  ## 0.0.11 (2022-01-21)
4
30
 
5
31
  * Drop support for Ruby 2.4 and 2.5
@@ -7,24 +33,78 @@
7
33
 
8
34
  ## 0.0.10 (2021-08-31)
9
35
 
10
- * Pull in upstream master. See
11
- https://github.com/SmartBear/ruby-handlebars/blob/2a8ce9ef584f2c34cd5714a4ed36711c2dd9d58a/CHANGELOG.md
12
- for included changes
36
+ * Pull in upstream master. See below for included changes
13
37
  * Make helpers with only optional arguments work in replacement form
14
38
 
39
+ ### from ruby-handlebars, released in [ruby-handlebars 0.4.1]
40
+
41
+ - use separate context for each template evaluation ([#33](https://github.com/SmartBear/ruby-handlebars/pull/33) [@mvz])
42
+ - added `with`helper ([#28](https://github.com/SmartBear/ruby-handlebars/pull/28) [@creature])
43
+ - Faster parsing ([#26](https://github.com/SmartBear/ruby-handlebars/pull/26) - [@mvz])
44
+
45
+ [ruby-handlebars 0.4.1]: https://github.com/smartbear/ruby-handlebars/compare/v0.4.0...v0.4.1
46
+
15
47
  ## 0.0.9 (2021-01-04)
16
48
 
17
- * Pull in upstream master. See
18
- https://github.com/SmartBear/ruby-handlebars/blob/44dc6800dd5006865fc2dc1c26a9d4e5c1411bce/CHANGELOG.md
19
- for included changes
49
+ * Pull in upstream master. See below for included changes
20
50
  * Prefer variable over helper when processing a replacement if the helper has
21
51
  the wrong arity
22
52
 
23
- ## 0.0.8
53
+ ### [ruby-handlebars 0.4.0] (2019/10/22)
54
+
55
+ - Allow slash character in partial names ([#18](https://github.com/SmartBear/ruby-handlebars/pull/18) - [@d316])
56
+ - Add parameters for partials ([#19](https://github.com/SmartBear/ruby-handlebars/pull/19) [#20](https://github.com/SmartBear/ruby-handlebars/pull/20) - [@d316])
57
+
58
+ ### [ruby-handlebars 0.3.0] (2019/10/11)
59
+
60
+ - Support helpers with "as" notation (`{{each items as |item|}}`)
61
+
62
+ ### [ruby-handlebars 0.2.1] (2019/8/30)
63
+
64
+ - allow "else" word as being part of a path (eg: {{ my.something.else }} is okay)
65
+
66
+ ### [ruby-handlebars 0.2.0] (2019/8/30)
67
+
68
+ - allow dash in identifiers ([#15](https://github.com/SmartBear/ruby-handlebars/pull/15) - [@stewartmckee])
69
+ - add "unless" helper
70
+ - add "helperMissing" helper, called when a helper is missing
71
+ - "else" keyword is now handled by the parser directly
72
+
73
+ ### [ruby-handlebars 0.1.1] (2019/6/26)
74
+
75
+ - with_temporary_context returns the result produced by the block
76
+
77
+ ### [ruby-handlebars 0.1.0] (2019/6/26)
78
+
79
+ - add 'with_temporary_context' in context to define temporary variables
80
+ - enable @index, @first and @last variables in "each" helper ([#10](https://github.com/SmartBear/ruby-handlebars/pull/10) - [@schuetzm])
81
+ - allow specifying escaper when using double curly braces
82
+ - allow using helper calls as arguments ([#11](https://github.com/SmartBear/ruby-handlebars/pull/11) - [@schuetzm])
83
+ - escape trice-braces replacements ([#9](https://github.com/SmartBear/ruby-handlebars/pull/9) - [@schuetzm])
84
+ - allow non-hash data ([#8](https://github.com/SmartBear/ruby-handlebars/pull/8) - [@mvz])
85
+ - allow single curly braces in content ([#7](https://github.com/SmartBear/ruby-handlebars/pull/7) - [@mvz])
86
+ - allow empty literal string arguments ([pr6]https://github.com/SmartBear/ruby-handlebars/pull/6) - [@mvz])
87
+
88
+ <!-- Contributors lists -->
89
+ [@stewartmckee]: https://github.com/stewartmckee
90
+ [@schuetzm]: https://github.com/schuetzm
91
+ [@mvz]: https://github.com/mvz
92
+ [@d316]: https://github.com/d316
93
+ [@creature]: https://github.com/creature
94
+
95
+ <!-- Releases diffs -->
96
+ [ruby-handlebars 0.4.0]: https://github.com/smartbear/ruby-handlebars/compare/v0.3.0...v0.4.0
97
+ [ruby-handlebars 0.3.0]: https://github.com/smartbear/ruby-handlebars/compare/v0.2.1...v0.3.0
98
+ [ruby-handlebars 0.2.1]: https://github.com/smartbear/ruby-handlebars/compare/v0.2.0...v0.2.1
99
+ [ruby-handlebars 0.2.0]: https://github.com/smartbear/ruby-handlebars/compare/v0.1.1...v0.2.0
100
+ [ruby-handlebars 0.1.1]: https://github.com/smartbear/ruby-handlebars/compare/v0.1.0...v0.1.1
101
+ [ruby-handlebars 0.1.0]: https://github.com/smartbear/ruby-handlebars/compare/v0.0.6...v0.1.0
102
+
103
+ ## 0.0.8 (2020-11-27)
24
104
 
25
105
  * Update dependencies
26
106
 
27
- ## 0.0.7
107
+ ## 0.0.7 (2019-05-13)
28
108
 
29
109
  * Set up forked gem mvz-ruby-handlebars
30
110
  * Several improvements
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ruby-handlebars
2
2
  ===============
3
3
 
4
- [![Build Status](https://travis-ci.org/mvz/ruby-handlebars.svg?branch=master)](https://travis-ci.org/mvz/ruby-handlebars)
4
+ [![Build status](https://github.com/mvz/ruby-handlebars/actions/workflows/ruby.yml/badge.svg)](https://github.com/mvz/ruby-handlebars/actions/workflows/ruby.yml)
5
5
 
6
6
  Pure Ruby library for [Handlebars](http://handlebarsjs.com/) template system.
7
7
  This should become an alternative for using the Handlebars javascript library via
data/Rakefile CHANGED
@@ -1,9 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'rake/clean'
4
- require 'bundler/gem_tasks'
5
- require 'rspec/core/rake_task'
3
+ require "rake/clean"
4
+ require "bundler/gem_tasks"
5
+ require "rspec/core/rake_task"
6
6
 
7
- RSpec::Core::RakeTask.new('spec')
7
+ RSpec::Core::RakeTask.new("spec")
8
8
 
9
9
  task default: :spec
@@ -6,7 +6,7 @@ module Handlebars
6
6
  end
7
7
 
8
8
  def get(path)
9
- items = path.split('.'.freeze)
9
+ items = path.split(".".freeze)
10
10
  if locals.key? items.first.to_sym
11
11
  current = locals
12
12
  else
@@ -1,4 +1,4 @@
1
- require 'cgi'
1
+ require "cgi"
2
2
 
3
3
  module Handlebars
4
4
  module Escapers
@@ -1,4 +1,4 @@
1
- require_relative 'tree'
1
+ require_relative "tree"
2
2
 
3
3
  module Handlebars
4
4
  class Helper
@@ -1,10 +1,10 @@
1
- require_relative 'default_helper'
1
+ require_relative "default_helper"
2
2
 
3
3
  module Handlebars
4
4
  module Helpers
5
5
  class EachHelper < DefaultHelper
6
6
  def self.registry_name
7
- 'each'
7
+ "each"
8
8
  end
9
9
 
10
10
  def self.apply(context, items, block, else_block)
@@ -21,7 +21,7 @@ module Handlebars
21
21
  result = items.each_with_index.map do |item, index|
22
22
  context.add_items(name => item, :@index => index, :@first => (index == 0), :@last => (index == items.length - 1))
23
23
  block.fn(context)
24
- end.join('')
24
+ end.join("")
25
25
  end
26
26
  end
27
27
  result
@@ -1,4 +1,4 @@
1
- require_relative 'default_helper'
1
+ require_relative "default_helper"
2
2
 
3
3
  module Handlebars
4
4
  class UnknownHelper < StandardError
@@ -7,7 +7,7 @@ module Handlebars
7
7
  module Helpers
8
8
  class HelperMissingHelper < DefaultHelper
9
9
  def self.registry_name
10
- 'helperMissing'
10
+ "helperMissing"
11
11
  end
12
12
 
13
13
  def self.apply(context, name, block, else_block)
@@ -1,10 +1,10 @@
1
- require_relative 'default_helper'
1
+ require_relative "default_helper"
2
2
 
3
3
  module Handlebars
4
4
  module Helpers
5
5
  class IfHelper < DefaultHelper
6
6
  def self.registry_name
7
- 'if'
7
+ "if"
8
8
  end
9
9
 
10
10
  def self.apply(context, condition, block, else_block)
@@ -1,8 +1,8 @@
1
- require_relative 'each_helper'
2
- require_relative 'helper_missing_helper'
3
- require_relative 'if_helper'
4
- require_relative 'unless_helper'
5
- require_relative 'with_helper'
1
+ require_relative "each_helper"
2
+ require_relative "helper_missing_helper"
3
+ require_relative "if_helper"
4
+ require_relative "unless_helper"
5
+ require_relative "with_helper"
6
6
 
7
7
  module Handlebars
8
8
  module Helpers
@@ -1,10 +1,10 @@
1
- require_relative 'default_helper'
1
+ require_relative "default_helper"
2
2
 
3
3
  module Handlebars
4
4
  module Helpers
5
5
  class UnlessHelper < DefaultHelper
6
6
  def self.registry_name
7
- 'unless'
7
+ "unless"
8
8
  end
9
9
 
10
10
  def self.apply(context, condition, block, else_block)
@@ -1,10 +1,10 @@
1
- require_relative 'default_helper'
1
+ require_relative "default_helper"
2
2
 
3
3
  module Handlebars
4
4
  module Helpers
5
5
  class WithHelper < DefaultHelper
6
6
  def self.registry_name
7
- 'with'
7
+ "with"
8
8
  end
9
9
 
10
10
  def self.apply(context, data, block, else_block)
@@ -1,39 +1,37 @@
1
- require 'parslet'
1
+ require "parslet"
2
2
 
3
3
  module Handlebars
4
4
  class Parser < Parslet::Parser
5
5
  rule(:space) { match('\s').repeat(1) }
6
6
  rule(:space?) { space.maybe }
7
- rule(:dot) { str('.') }
8
- rule(:gt) { str('>')}
9
- rule(:hash) { str('#')}
10
- rule(:slash) { str('/')}
11
- rule(:ocurly) { str('{')}
12
- rule(:ccurly) { str('}')}
13
- rule(:pipe) { str('|')}
14
- rule(:eq) { str('=')}
7
+ rule(:dot) { str(".") }
8
+ rule(:gt) { str(">")}
9
+ rule(:hash) { str("#")}
10
+ rule(:slash) { str("/")}
11
+ rule(:ocurly) { str("{")}
12
+ rule(:ccurly) { str("}")}
13
+ rule(:pipe) { str("|")}
14
+ rule(:eq) { str("=")}
15
15
 
16
16
 
17
- rule(:docurly) { ocurly >> ocurly }
18
- rule(:dccurly) { ccurly >> ccurly }
19
- rule(:tocurly) { ocurly >> ocurly >> ocurly }
20
- rule(:tccurly) { ccurly >> ccurly >> ccurly }
17
+ rule(:docurly) { str("{{") }
18
+ rule(:dccurly) { str("}}") }
19
+ rule(:tocurly) { str("{{{") }
20
+ rule(:tccurly) { str("}}}") }
21
21
 
22
- rule(:else_kw) { str('else') }
23
- rule(:as_kw) { str('as') }
22
+ rule(:else_kw) { str("else") }
23
+ rule(:as_kw) { str("as") }
24
24
 
25
25
  rule(:identifier) { (else_kw >> space? >> dccurly).absent? >> match['@\-a-zA-Z0-9_\?'].repeat(1) }
26
26
  rule(:directory) { (else_kw >> space? >> dccurly).absent? >> match['@\-a-zA-Z0-9_\/\?'].repeat(1) }
27
27
  rule(:path) { identifier >> (dot >> (identifier | else_kw)).repeat }
28
28
 
29
- rule(:nocurly) { match('[^{}]') }
29
+ rule(:noocurly) { match("[^{]") }
30
30
  rule(:eof) { any.absent? }
31
31
  rule(:template_content) {
32
32
  (
33
- nocurly.repeat(1) | # A sequence of non-curlies
34
- ocurly >> nocurly | # Opening curly that doesn't start a {{}}
35
- ccurly | # Closing curly that is not inside a {{}}
36
- ocurly >> eof # Opening curly that doesn't start a {{}} because it's the end
33
+ noocurly.repeat(1) | # A sequence of non-opening-curlies
34
+ ocurly >> (noocurly | eof) # Opening curly that doesn't start a {{}}
37
35
  ).repeat(1).as(:template_content) }
38
36
 
39
37
  rule(:unsafe_replacement) { docurly >> space? >> path.as(:replaced_unsafe_item) >> space? >> dccurly }
@@ -47,7 +45,7 @@ module Handlebars
47
45
  (as_kw >> space? >> pipe).absent? >>
48
46
  (
49
47
  (path | string).as(:parameter_name) |
50
- (str('(') >> space? >> identifier.as(:safe_helper_name) >> (space? >> parameters.as(:parameters)).maybe >> space? >> str(')'))
48
+ (str("(") >> space? >> identifier.as(:safe_helper_name) >> (space? >> parameters.as(:parameters)).maybe >> space? >> str(")"))
51
49
  )
52
50
  }
53
51
  rule(:parameters) { parameter >> (space >> parameter).repeat }
@@ -1,4 +1,4 @@
1
- require_relative 'context'
1
+ require_relative "context"
2
2
 
3
3
  module Handlebars
4
4
  class Template
@@ -1,4 +1,4 @@
1
- require 'parslet'
1
+ require "parslet"
2
2
 
3
3
  module Handlebars
4
4
  module Tree
@@ -51,7 +51,7 @@ module Handlebars
51
51
  def _eval(context)
52
52
  helper = context.get_helper(name.to_s)
53
53
  if helper.nil?
54
- context.get_helper('helperMissing').apply(context, String.new(name.to_s))
54
+ context.get_helper("helperMissing").apply(context, String.new(name.to_s))
55
55
  else
56
56
  helper.apply(context, parameters, block, else_block)
57
57
  end
@@ -62,7 +62,7 @@ module Handlebars
62
62
  def _eval(context)
63
63
  helper = context.get_as_helper(name.to_s)
64
64
  if helper.nil?
65
- context.get_helper('helperMissing').apply(context, String.new(name.to_s))
65
+ context.get_helper("helperMissing").apply(context, String.new(name.to_s))
66
66
  else
67
67
  helper.apply_as(context, parameters, as_parameters, block, else_block)
68
68
  end
@@ -1,3 +1,3 @@
1
1
  module Handlebars
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
@@ -1,11 +1,11 @@
1
- require_relative 'ruby-handlebars/version'
2
- require_relative 'ruby-handlebars/context'
3
- require_relative 'ruby-handlebars/parser'
4
- require_relative 'ruby-handlebars/tree'
5
- require_relative 'ruby-handlebars/template'
6
- require_relative 'ruby-handlebars/helper'
7
- require_relative 'ruby-handlebars/helpers/register_default_helpers'
8
- require_relative 'ruby-handlebars/escapers/html_escaper'
1
+ require_relative "ruby-handlebars/version"
2
+ require_relative "ruby-handlebars/context"
3
+ require_relative "ruby-handlebars/parser"
4
+ require_relative "ruby-handlebars/tree"
5
+ require_relative "ruby-handlebars/template"
6
+ require_relative "ruby-handlebars/helper"
7
+ require_relative "ruby-handlebars/helpers/register_default_helpers"
8
+ require_relative "ruby-handlebars/escapers/html_escaper"
9
9
 
10
10
  module Handlebars
11
11
  class Handlebars