curlybars 1.10.0 → 1.11.0

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: a21d1b2f9bc23315fd45fc0f3e1f1dba730d7d7555b221968956635e00f2f989
4
- data.tar.gz: d834d004783806af09cec7fa411bd5184529a30b1d60995cebcba564d54cd5e5
3
+ metadata.gz: 75e0f6f2934a512ad3ba98455f3eab1492ddd131489322d4082a19cf9568b1cc
4
+ data.tar.gz: 9e36b98d7c878e4083ca27f34a7daccc2eee4f39bb6e4e5040c186a806321f87
5
5
  SHA512:
6
- metadata.gz: '066406790ee118acfcd150c5d604e41298dfca0436be419482e05a71253396827c2314313036dfe03d853a01e2b615fec66ab26fa43058fbd94fa27160dad970'
7
- data.tar.gz: 21580e1338a0200d0210e298752030320c38fbf7a9f1021912ee638d5b4a3492bfdae79e64eb754f919fb34d17f88c74f624e5aaab577bf566dcaf31ef173188
6
+ metadata.gz: 6aeb6a8ace0d10637dcc0a9be64fc23e150d1971afb01d4ce8c735d9740e6a1f1644c33cd662dbd3fbbaa9e2b8b34a2c76aa735d064eb08118dd54435c3eb5c9
7
+ data.tar.gz: fd1289f763c7870e921120b849a1f1fa8de334c9998e8ca34fc4758384a83fc62ac86070b382b934f47961a4f0b7073c49ade00ebb77572b0d419d7e8a5d8677
@@ -100,6 +100,17 @@ module Curlybars
100
100
  define_method(:allows_method?) do |method|
101
101
  allowed_methods.include?(method)
102
102
  end
103
+
104
+ define_method(:as_json) do |*args|
105
+ return @__as_json if defined?(@__as_json)
106
+
107
+ @__as_json ||= allowed_methods.each_with_object({}) do |method, hash|
108
+ unless self.method(method).arity > 0
109
+ value = send(method)
110
+ hash[method] = value.equal?(self) ? "[circular reference]" : value.as_json
111
+ end
112
+ end
113
+ end
103
114
  end
104
115
 
105
116
  def self.extended(base)
@@ -79,6 +79,18 @@ module Curlybars
79
79
  arguments.map { |argument| argument.validate_as_value(branches) },
80
80
  options.map { |option| option.validate(branches) }
81
81
  ]
82
+ elsif helper.generic_helper?(branches)
83
+ if arguments.empty?
84
+ message = "#{helper.path} requires an argument"
85
+ Curlybars::Error::Validate.new('invalid_signature', message, helper.position)
86
+ else
87
+ [
88
+ helper_template.validate(branches),
89
+ else_template.validate(branches),
90
+ arguments.map { |argument| argument.validate(branches, check_type: :anything) },
91
+ options.map { |option| option.validate(branches) }
92
+ ]
93
+ end
82
94
  else
83
95
  message = "#{helper.path} must be allowed as helper or leaf"
84
96
  Curlybars::Error::Validate.new('invalid_block_helper', message, helper.position)
@@ -1,3 +1,3 @@
1
1
  module Curlybars
2
- VERSION = '1.10.0'.freeze
2
+ VERSION = '1.11.0'.freeze
3
3
  end
data/lib/curlybars.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'digest'
2
2
  require 'active_support/cache'
3
+ require 'active_support/core_ext/object/json'
3
4
  require 'curlybars/version'
4
5
 
5
6
  # Curlybars is a view system based on Curly that uses Handlebars syntax.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: curlybars
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Libo Cannici
@@ -15,7 +15,7 @@ authors:
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
- date: 2024-01-16 00:00:00.000000000 Z
18
+ date: 2024-02-27 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: actionpack