rblade 0.2.0 → 0.2.2

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: 388670a7f7f3d90c6249e149cd51e898dbadc66d182e0d0111948677cb85719c
4
- data.tar.gz: 8dd2d5415191fb833a850b9ba9f2e0fd1d51a3722d466cd410c28c9c02e079dd
3
+ metadata.gz: aef0eb02d400c2a6af0c114d0952d9871cb83866fa6fbdf43d72eddd555344c2
4
+ data.tar.gz: 72c5ae0785f172248afd031acd15f3608f6f7cb2e313fcfeeaaa432dcf5bc344
5
5
  SHA512:
6
- metadata.gz: 65742f3fbb5ffca6bbbf05e94b4d9838cbf488ae835c1607abdb73cca9c04308a5de142a356ecdbd374019eb73ef3a6ccbe9dec732fceaa555ab580ca0a7ebec
7
- data.tar.gz: 0bb1616971c4dc02d919f9c432bf478e2f18a2021116834aac10e7be340720e0f75855c997beb5a45fb8c456cb980d5dfeaa7e44e49681c28c1643b1b168d15d
6
+ metadata.gz: 0425f57b22af0ced7dbe28fe25a88da21d5d5cfd4960ebb22a6fd6b53108cb9af6eb2e01b31e9fae919478cc38ddca9bffe23f05439e58f3f4dbb2665ee39fa2
7
+ data.tar.gz: 64c90f0edddc6b534f1104240788bb8fe7afc7dd78a06ca037d24228b5127746380d41fabb7473c827c7327abe26362c97a8ad5e2090393b68887061e0d3fbad
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.2.2 [2024-07-23]
2
+ - Change comments to be compiled first
3
+
4
+ ## 0.2.1 [2024-07-23]
5
+ - Add support for attributes pass through in components
6
+
1
7
  ## 0.2.0 [2024-07-23]
2
8
  - Fix slots being calculated without parent's context
3
9
  - 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
  (?:
@@ -23,10 +23,10 @@ module RBlade
23
23
  tokens = [Token.new(:unprocessed, string_template)]
24
24
 
25
25
  CompilesComments.new.compile! tokens
26
- CompilesEchos.new.compile! tokens
27
26
  CompilesRuby.new.compile! tokens
28
27
  TokenizesComponents.new.tokenize! tokens
29
28
  TokenizesStatements.new.tokenize! 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.2"
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.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon J