rblade 1.1.0 → 1.1.1

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: edaa1af6299a8281520a73611def0838ef1017f2ec7bb3fd8a125bcd02e5c7ce
4
- data.tar.gz: 6363e44a009a29e8771c50ecf4768b0d365b0d2147ba998db72805e9b05c0390
3
+ metadata.gz: 12abc58f2de63aabc65abf34fe60b17b63b8ba70141dbd16447d6d5b42b84a0a
4
+ data.tar.gz: 101e136868a7cbb2d5eb7ab2d117b90013999c1dcd544726fa9a0423a3b6566e
5
5
  SHA512:
6
- metadata.gz: 996e77805b56530e9f136c087753938c10c8dc71d45b1fbaec10e81e890878b9a0da00a10fa024a650cb2e463e155fe8da723fb16a6eb690f5811915ce4fe879
7
- data.tar.gz: 5bbe562c01ec5fb12e77cb53aa2991cebfd83792dd831a41957497e3b04e29df442511c890d48fcb05bef78107cf5347019c49c7c8dc9e5d3f9ef0557a63f940
6
+ metadata.gz: 6a96e14502ccb338afc0779779f8d18901b9f8ea4ef90ba26e0142d24acc7f8a8cac85e290f3109a92b7d82c5752da795481084c733810dc3ffcfed97302a6c4
7
+ data.tar.gz: 0a17982fdb228fb5edaa308e9dbb2c58a16c9733d2bd5bbe89188a4bb1431940558be5904a41d02093fe9ae5346b631a98bcd2dd825fe72e47de390e85912343
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 1.1.1 [2024-08-23]
2
+ - Remove requirement for including braces in `@props` directive
3
+
1
4
  ## 1.1.0 [2024-08-23]
2
5
  - Add `@eachWithIndex` directive
3
6
  - Fix attribute manager output of attributes with no value (#10)
data/README.md CHANGED
@@ -491,7 +491,7 @@ You can define a component's data properties using a `@props` directive at the t
491
491
 
492
492
  ```rblade
493
493
  {{-- alert.rblade --}}
494
- @props({type: "warning", message: required})
494
+ @props(type: "warning", message: required)
495
495
  <div class="{{ type }}">{{ message }}</div>
496
496
  ```
497
497
 
@@ -505,7 +505,7 @@ The `@props` directive accepts a Hash where the key is the name of the attribute
505
505
  All properties in the `@props` directive are automatically removed from `attributes`. Properties with names that aren't valid Ruby variable names or are Ruby reserved keywords are not created as local variables. However, you can reference them via the `attributes` local variable:
506
506
 
507
507
  ```rblade
508
- @props({"for": required, "data-value": nil})
508
+ @props("for": required, "data-value": nil)
509
509
  <div>{{ attributes[:for] }} {{ attributes[:'data-value'] }}</div>
510
510
  ```
511
511
 
@@ -697,7 +697,7 @@ Sometimes a component may need to render multiple different slots in different l
697
697
 
698
698
  ```rblade
699
699
  {{-- /app/views/components/alert.rblade --}}
700
- @props({title: required})
700
+ @props(title: required)
701
701
  <span class="alert-title">{{ title }}</span>
702
702
  <div class="alert alert-danger">
703
703
  {{ slot }}
@@ -752,10 +752,10 @@ Like RBlade components, you can assign additional [attributes](#component-attrib
752
752
  To interact with slot attributes, you can access the `attributes` property of the slot's variable. For more information on how to interact with attributes, please consult the documentation on [component attributes](#component-attributes):
753
753
 
754
754
  ```rblade
755
- @props({
755
+ @props(
756
756
  "heading": required,
757
757
  "footer": required,
758
- })
758
+ )
759
759
 
760
760
  <div {{ attributes.class('border') }}>
761
761
  <h1 {{ heading.attributes.class('text-lg') }}>
@@ -777,7 +777,7 @@ Sometimes, you may wish to return early from a component without printing anythi
777
777
 
778
778
  ```rblade
779
779
  {{-- components/error.rblade --}}
780
- @props({errors: []})
780
+ @props(errors: [])
781
781
  @shouldRender(errors.present?)
782
782
  ...
783
783
  ```
data/REFERENCE.md CHANGED
@@ -30,8 +30,8 @@ By default, RBlade will look for components in the `app/views/components` folder
30
30
  | `<x-name @style({'bg-red-600': is_error})/>` | Conditionally pass styles to a component |
31
31
  | `<x-name attribute/>` | Pass an attribute to a component with value `true` |
32
32
  | `<x-name {{ attributes }}/>` | Pass attributes to a child component |
33
- | `@props({header: "Header"})` | Remove `header` from the attributes Hash and introduce it as a local variable, using the specified value as a default |
34
- | `@props({header: required})` | Remove `header` from the attributes Hash and introduce it as a local variable, raising an error if it is not set |
33
+ | `@props(header: "Header")` | Remove `header` from the attributes Hash and introduce it as a local variable, using the specified value as a default |
34
+ | `@props(header: required)` | Remove `header` from the attributes Hash and introduce it as a local variable, raising an error if it is not set |
35
35
  | `{{ slot }}` | Output the block content passed into the current component |
36
36
  | `<x-name><x-slot::header><h1>Header</h1><//>Content<//>` | Pass a named block to a component |
37
37
  | `{{ header }}` | Output the contents of a named block |
@@ -42,12 +42,12 @@ module RBlade
42
42
  private
43
43
 
44
44
  def extractProps prop_string
45
- if !prop_string.start_with?("{") || !prop_string.end_with?("}")
46
- raise StandardError.new "Props statement: expecting hash as parameter"
45
+ if prop_string.start_with?("{") && prop_string.end_with?("}")
46
+ prop_string = prop_string.delete_prefix("{").delete_suffix("}")
47
47
  end
48
48
 
49
49
  props = {}
50
- prop_strings = Tokenizer.extractCommaSeparatedValues prop_string[1..-2]
50
+ prop_strings = Tokenizer.extractCommaSeparatedValues prop_string
51
51
 
52
52
  prop_strings.each do |prop|
53
53
  prop.strip!
data/rblade.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "rblade"
3
- s.version = "1.1.0"
3
+ s.version = "1.1.1"
4
4
  s.summary = "A component-first templating engine for Rails"
5
5
  s.description = "RBlade is a simple, yet powerful templating engine for Ruby on Rails, inspired by Laravel Blade."
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: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon J