liquidz 0.2.8-arm64-darwin-23

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a120d8b233bc59fda2dbd41375970b65c24e000811e906f7800026ff067fd5ab
4
+ data.tar.gz: f6298230bccc9c2974536e510acd51be9097055ccddaad0a0c741b2740c26116
5
+ SHA512:
6
+ metadata.gz: f8218df9bc226d035bcb6a6c5a331e3558a5e678b5e4c95c677280b87e6ded0f657cdfb55ecac44e07d5f89de8e9d1e018287895dd8b53a0698ebca23daff3e4
7
+ data.tar.gz: 7340cf460bbc3edd7afe3c244ddffc59c0770b9876e28e04be06f2fa50799244b3c6e5aa1864078058c30af9ce6e09e7809c8cd2869d686e4160d01b4431c968
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Pedro Piñera Buendía
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,101 @@
1
+ # Liquidz Ruby Binding
2
+
3
+ High-performance Liquid template engine for Ruby, powered by Zig.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'liquidz'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```bash
16
+ bundle install
17
+ ```
18
+
19
+ Or install it yourself:
20
+
21
+ ```bash
22
+ gem install liquidz
23
+ ```
24
+
25
+ **Prerequisites:** You need to build the Zig library first:
26
+
27
+ ```bash
28
+ zig build -Doptimize=ReleaseFast
29
+ ```
30
+
31
+ Then build the gem extension:
32
+
33
+ ```bash
34
+ cd ext/liquidz_ext
35
+ ruby extconf.rb
36
+ make
37
+ ```
38
+
39
+ ## Usage
40
+
41
+ ```ruby
42
+ require 'liquidz_ext'
43
+
44
+ # Simple variable substitution
45
+ result = Liquidz.render("Hello, {{ name }}!", { name: "World" })
46
+ # => "Hello, World!"
47
+
48
+ # With loops
49
+ result = Liquidz.render("{% for item in items %}{{ item }} {% endfor %}", { items: ["a", "b", "c"] })
50
+ # => "a b c "
51
+
52
+ # With conditionals
53
+ result = Liquidz.render("{% if show %}visible{% endif %}", { show: true })
54
+ # => "visible"
55
+
56
+ # With filters
57
+ result = Liquidz.render("{{ name | upcase }}", { name: "hello" })
58
+ # => "HELLO"
59
+
60
+ # Using JSON string directly
61
+ result = Liquidz.render("{{ x }}", '{"x": 42}')
62
+ # => "42"
63
+ ```
64
+
65
+ ## Drop-in Replacement for Liquid
66
+
67
+ Liquidz can act as a drop-in replacement for the standard Liquid gem:
68
+
69
+ ```ruby
70
+ require 'liquidz_ext/liquid_patch'
71
+
72
+ # Now Liquid::Template.parse uses Liquidz under the hood
73
+ template = Liquid::Template.parse("Hello, {{ name }}!")
74
+ result = template.render({ "name" => "World" })
75
+ # => "Hello, World!"
76
+ ```
77
+
78
+ ## API
79
+
80
+ ### `Liquidz.render(template, data = nil)`
81
+
82
+ Renders a Liquid template with the given data.
83
+
84
+ - `template` (String): The Liquid template string
85
+ - `data` (Hash, String, nil): The data to render with. Can be a Hash or a JSON string. Defaults to `nil`.
86
+
87
+ Returns the rendered template as a String.
88
+
89
+ Raises `RuntimeError` if rendering fails.
90
+
91
+ ### `Liquidz.render_string(template, data = nil)`
92
+
93
+ Alias for `Liquidz.render`.
94
+
95
+ ## Performance
96
+
97
+ Liquidz is approximately 3.3x faster than the standard Ruby Liquid gem for typical templates.
98
+
99
+ ## License
100
+
101
+ MIT
@@ -0,0 +1,36 @@
1
+ require "liquid"
2
+ require "liquidz_ext"
3
+
4
+ module Liquidz
5
+ class Template
6
+ def initialize(source)
7
+ @source = source
8
+ end
9
+
10
+ def render(context = {}, **_opts)
11
+ Liquidz.render(@source, context)
12
+ end
13
+
14
+ def render!(*args, **kwargs)
15
+ render(*args, **kwargs)
16
+ end
17
+ end
18
+
19
+ def self.enable_liquid_patch!
20
+ return if @liquid_patch_enabled
21
+
22
+ Liquid::Template.singleton_class.class_eval do
23
+ unless method_defined?(:liquidz_orig_parse)
24
+ alias_method :liquidz_orig_parse, :parse
25
+ end
26
+
27
+ def parse(source, *args, **_kwargs)
28
+ Liquidz::Template.new(source)
29
+ end
30
+ end
31
+
32
+ @liquid_patch_enabled = true
33
+ end
34
+ end
35
+
36
+ Liquidz.enable_liquid_patch!
Binary file
@@ -0,0 +1,46 @@
1
+ require "json"
2
+ require "liquidz_ext/liquidz_ext"
3
+
4
+ # Liquidz - High-performance Liquid template engine powered by Zig
5
+ #
6
+ # @example Basic usage
7
+ # Liquidz.render("Hello, {{ name }}!", { name: "World" })
8
+ # # => "Hello, World!"
9
+ #
10
+ # @example With loops
11
+ # Liquidz.render("{% for item in items %}{{ item }} {% endfor %}", { items: ["a", "b", "c"] })
12
+ # # => "a b c "
13
+ #
14
+ # @example With filters
15
+ # Liquidz.render("{{ name | upcase }}", { name: "hello" })
16
+ # # => "HELLO"
17
+ #
18
+ module Liquidz
19
+ class Error < StandardError; end
20
+ class RenderError < Error; end
21
+
22
+ # Renders a Liquid template with the given data.
23
+ #
24
+ # @param template [String] The Liquid template string
25
+ # @param data [Hash, String, nil] The data to render with (Hash or JSON string)
26
+ # @return [String] The rendered template
27
+ # @raise [RenderError] If rendering fails
28
+ #
29
+ # @example
30
+ # Liquidz.render_string("Hello, {{ name }}!", { name: "World" })
31
+ # # => "Hello, World!"
32
+ #
33
+ def self.render_string(template, data = nil)
34
+ render(template, data)
35
+ rescue => e
36
+ raise RenderError, "Failed to render template: #{e.message}"
37
+ end
38
+
39
+ # Returns the version of the Liquidz library.
40
+ #
41
+ # @return [String] The version string
42
+ #
43
+ def self.version
44
+ "0.2.0"
45
+ end
46
+ end
metadata ADDED
@@ -0,0 +1,66 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: liquidz
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.8
5
+ platform: arm64-darwin-23
6
+ authors:
7
+ - Pedro Pinera Buendia
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-01-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: A fast, drop-in replacement for the Liquid template engine, compiled
28
+ from Zig to native code for maximum performance.
29
+ email:
30
+ - pedro@ppinera.es
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - LICENSE
36
+ - README.md
37
+ - lib/liquidz_ext.rb
38
+ - lib/liquidz_ext/liquid_patch.rb
39
+ - lib/liquidz_ext/liquidz_ext.bundle
40
+ homepage: https://github.com/pepicrft/liquidz
41
+ licenses:
42
+ - MIT
43
+ metadata:
44
+ homepage_uri: https://github.com/pepicrft/liquidz
45
+ source_code_uri: https://github.com/pepicrft/liquidz
46
+ changelog_uri: https://github.com/pepicrft/liquidz/blob/main/CHANGELOG.md
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 2.7.0
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubygems_version: 3.5.22
63
+ signing_key:
64
+ specification_version: 4
65
+ summary: High-performance Liquid template engine powered by Zig
66
+ test_files: []