rblade 0.2.0 → 0.2.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: 388670a7f7f3d90c6249e149cd51e898dbadc66d182e0d0111948677cb85719c
4
- data.tar.gz: 8dd2d5415191fb833a850b9ba9f2e0fd1d51a3722d466cd410c28c9c02e079dd
3
+ metadata.gz: 6d55092cb6f64266006466fb9fcb1f6f9de30bb1a2df18e5ed123a7778f694c8
4
+ data.tar.gz: bd6ed6fca05f62d0cd606d53addbb27ecbabe1b32dcdd76f2a150d6227e3c6f6
5
5
  SHA512:
6
- metadata.gz: 65742f3fbb5ffca6bbbf05e94b4d9838cbf488ae835c1607abdb73cca9c04308a5de142a356ecdbd374019eb73ef3a6ccbe9dec732fceaa555ab580ca0a7ebec
7
- data.tar.gz: 0bb1616971c4dc02d919f9c432bf478e2f18a2021116834aac10e7be340720e0f75855c997beb5a45fb8c456cb980d5dfeaa7e44e49681c28c1643b1b168d15d
6
+ metadata.gz: '0821ffdde4f0e0ba9763c37e6f167a1e990aa7ef912b19561aa6f5f97ff90b0ddc4cbee7472bb73d2d31f0ef0d560ec81f47ab92a68a0280478a054d4c133bf4'
7
+ data.tar.gz: 450ae054965627db91899496ed5fefa3f34cb057710f7377941d196b0a6e753eea7c41ff8f5082174947f30a702ab8e346dea19f6de6e5ecdbf7e8492e1767db
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.2.1 [2024-07-23]
2
+ - Add support for attributes pass through in components
3
+
1
4
  ## 0.2.0 [2024-07-23]
2
5
  - Fix slots being calculated without parent's context
3
6
  - Add @props statement
@@ -39,6 +39,9 @@ module RBlade
39
39
 
40
40
  def compile_token_end token
41
41
  component = @component_stack.pop
42
+ if component.nil?
43
+ raise StandardError.new "Unexpected closing tag (#{token.value[:name]})"
44
+ end
42
45
  if token.value[:name] != component[:name]
43
46
  raise StandardError.new "Unexpected closing tag (#{token.value[:name]}) expecting #{component[:name]}"
44
47
  end
@@ -73,6 +76,12 @@ module RBlade
73
76
 
74
77
  next
75
78
  end
79
+ if attribute[:type] == "attributes"
80
+ attribute_arguments.push "**attributes.to_h"
81
+ attribute_assignments.push "_style = attributes[:style];"
82
+
83
+ next
84
+ end
76
85
 
77
86
  if attribute[:type] == "string"
78
87
  attribute_arguments.push "'#{attribute[:name]}': '#{RBlade.escape_quotes(attribute[:value])}'"
@@ -57,9 +57,9 @@ module RBlade
57
57
  if name == "@class" || name == "@style"
58
58
  attributes.push({type: name[1..], value: raw_attributes[i + 1][1..-2]})
59
59
  i += 2
60
- elsif name[0..1] == "{{"
61
- attributes.push({type: "attributes", value: raw_attributes[i + 1][2..-2]})
62
- i += 1
60
+ elsif name == "{{"
61
+ attributes.push({type: "attributes", value: raw_attributes[i + 1]})
62
+ i += 3
63
63
  else
64
64
  attribute = {name:}
65
65
 
@@ -116,7 +116,7 @@ module RBlade
116
116
  )
117
117
  |
118
118
  (
119
- \{\{\s*attributes(?:[^}]+?)?\s*\}\}
119
+ \{\{\s*attributes.*?\s*\}\}
120
120
  )
121
121
  |
122
122
  (?:
@@ -163,7 +163,7 @@ module RBlade
163
163
  )
164
164
  |
165
165
  (?:
166
- (\{\{)\s*attributes([^}]+?)?\s*(\}\})
166
+ (\{\{)\s*(attributes.*?)\s*(\}\})
167
167
  )
168
168
  |
169
169
  (?:
@@ -22,11 +22,11 @@ module RBlade
22
22
  def self.compileString(string_template)
23
23
  tokens = [Token.new(:unprocessed, string_template)]
24
24
 
25
- CompilesComments.new.compile! tokens
26
- CompilesEchos.new.compile! tokens
27
25
  CompilesRuby.new.compile! tokens
28
26
  TokenizesComponents.new.tokenize! tokens
29
27
  TokenizesStatements.new.tokenize! tokens
28
+ CompilesComments.new.compile! tokens
29
+ CompilesEchos.new.compile! tokens
30
30
  CompilesStatements.new.compile! tokens
31
31
  CompilesComponents.new.compile! tokens
32
32
 
@@ -5,6 +5,10 @@ module RBlade
5
5
  @attributes = attributes
6
6
  end
7
7
 
8
+ def to_h
9
+ @attributes
10
+ end
11
+
8
12
  def to_s attributes = nil
9
13
  attributes ||= @attributes
10
14
 
data/rblade.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "rblade"
3
- s.version = "0.2.0"
3
+ s.version = "0.2.1"
4
4
  s.summary = "Blade templates for ruby"
5
5
  s.description = "A port of the Laravel blade templating engine to ruby"
6
6
  s.authors = ["Simon J"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rblade
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon J