mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-19 02:40:41 -07:00
Remove inline snippet specific example files
This commit is contained in:
@@ -29,7 +29,3 @@ group :test do
|
|||||||
gem 'rubocop-shopify', '~> 2.12.0', require: false
|
gem 'rubocop-shopify', '~> 2.12.0', require: false
|
||||||
gem 'rubocop-performance', require: false
|
gem 'rubocop-performance', require: false
|
||||||
end
|
end
|
||||||
|
|
||||||
group :development do
|
|
||||||
gem "webrick"
|
|
||||||
end
|
|
||||||
|
|||||||
@@ -1,74 +0,0 @@
|
|||||||
PATH
|
|
||||||
remote: .
|
|
||||||
specs:
|
|
||||||
liquid (5.8.7)
|
|
||||||
bigdecimal
|
|
||||||
strscan (>= 3.1.1)
|
|
||||||
|
|
||||||
GEM
|
|
||||||
remote: https://rubygems.org/
|
|
||||||
specs:
|
|
||||||
ast (2.4.2)
|
|
||||||
base64 (0.2.0)
|
|
||||||
benchmark-ips (2.13.0)
|
|
||||||
bigdecimal (3.2.3)
|
|
||||||
json (2.7.2)
|
|
||||||
language_server-protocol (3.17.0.3)
|
|
||||||
lru_redux (1.1.0)
|
|
||||||
memory_profiler (1.0.1)
|
|
||||||
minitest (5.22.3)
|
|
||||||
parallel (1.24.0)
|
|
||||||
parser (3.3.0.5)
|
|
||||||
ast (~> 2.4.1)
|
|
||||||
racc
|
|
||||||
racc (1.7.3)
|
|
||||||
rainbow (3.1.1)
|
|
||||||
rake (13.2.1)
|
|
||||||
regexp_parser (2.9.0)
|
|
||||||
rexml (3.2.6)
|
|
||||||
rubocop (1.61.0)
|
|
||||||
json (~> 2.3)
|
|
||||||
language_server-protocol (>= 3.17.0)
|
|
||||||
parallel (~> 1.10)
|
|
||||||
parser (>= 3.3.0.2)
|
|
||||||
rainbow (>= 2.2.2, < 4.0)
|
|
||||||
regexp_parser (>= 1.8, < 3.0)
|
|
||||||
rexml (>= 3.2.5, < 4.0)
|
|
||||||
rubocop-ast (>= 1.30.0, < 2.0)
|
|
||||||
ruby-progressbar (~> 1.7)
|
|
||||||
unicode-display_width (>= 2.4.0, < 3.0)
|
|
||||||
rubocop-ast (1.31.2)
|
|
||||||
parser (>= 3.3.0.4)
|
|
||||||
rubocop-performance (1.19.1)
|
|
||||||
rubocop (>= 1.7.0, < 2.0)
|
|
||||||
rubocop-ast (>= 0.4.0)
|
|
||||||
rubocop-shopify (2.12.0)
|
|
||||||
rubocop (~> 1.44)
|
|
||||||
ruby-progressbar (1.13.0)
|
|
||||||
stackprof (0.2.26)
|
|
||||||
strscan (3.1.5)
|
|
||||||
terminal-table (3.0.2)
|
|
||||||
unicode-display_width (>= 1.1.1, < 3)
|
|
||||||
unicode-display_width (2.5.0)
|
|
||||||
webrick (1.8.1)
|
|
||||||
|
|
||||||
PLATFORMS
|
|
||||||
ruby
|
|
||||||
|
|
||||||
DEPENDENCIES
|
|
||||||
base64
|
|
||||||
benchmark-ips
|
|
||||||
liquid!
|
|
||||||
lru_redux
|
|
||||||
memory_profiler
|
|
||||||
minitest
|
|
||||||
rake (~> 13.0)
|
|
||||||
rubocop (~> 1.61.0)
|
|
||||||
rubocop-performance
|
|
||||||
rubocop-shopify (~> 2.12.0)
|
|
||||||
stackprof
|
|
||||||
terminal-table
|
|
||||||
webrick
|
|
||||||
|
|
||||||
BUNDLED WITH
|
|
||||||
2.5.7
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
require 'bundler/inline'
|
|
||||||
|
|
||||||
gemfile(true) do
|
|
||||||
source "https://rubygems.org"
|
|
||||||
gem 'liquid'
|
|
||||||
end
|
|
||||||
|
|
||||||
require 'liquid'
|
|
||||||
|
|
||||||
class Parser
|
|
||||||
def initialize(template)
|
|
||||||
@template = template
|
|
||||||
end
|
|
||||||
|
|
||||||
def parse
|
|
||||||
@parsed_template = Liquid::Template.parse(@template)
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_parse
|
|
||||||
document = @parsed_template.root
|
|
||||||
|
|
||||||
variables = []
|
|
||||||
|
|
||||||
if document.is_a?(Liquid::Document)
|
|
||||||
body = document.body
|
|
||||||
|
|
||||||
if body.is_a?(Liquid::BlockBody)
|
|
||||||
body.nodelist.each do |node|
|
|
||||||
next unless node.is_a?(Liquid::Variable)
|
|
||||||
|
|
||||||
puts node.inspect
|
|
||||||
variable_name = node.name.name
|
|
||||||
variables << variable_name
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
puts "Variables: #{variables}"
|
|
||||||
end
|
|
||||||
|
|
||||||
def render
|
|
||||||
@parsed_template.render
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
starter_template = "{{ foo }}"
|
|
||||||
starter_template_2 = "{{foo}}, {{bar}}"
|
|
||||||
starter_template_2_1 = "{{ foo }} and {{ bar }}"
|
|
||||||
starter_template_3 = "{% assign foo = 'bar' %}{{ foo }}"
|
|
||||||
# Let's start small here
|
|
||||||
template = <<~LIQUID
|
|
||||||
{% assign foo = 'bar' %}
|
|
||||||
{{ foo }}
|
|
||||||
LIQUID
|
|
||||||
|
|
||||||
parser = Parser.new(starter_template)
|
|
||||||
parser.parse
|
|
||||||
parser.test_parse
|
|
||||||
@@ -1,43 +1,5 @@
|
|||||||
<!doctype html>
|
<p>Hello world!</p>
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Inline Snippets</title>
|
|
||||||
|
|
||||||
<body>
|
<p>It is {{ date }}</p>
|
||||||
<div class="liquid" style="font-size: 56px;">
|
|
||||||
|
|
||||||
{% assign foo = true %}
|
<p>Check out the <a href="/products">Products</a> screen</p>
|
||||||
{% assign linktext = "variable" %}
|
|
||||||
|
|
||||||
{% snippet main %}
|
|
||||||
{% assign foo = false %}
|
|
||||||
<p>Hi {{ arg | upcase }}!!!</p>
|
|
||||||
|
|
||||||
<p>This is an inline snippet</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><a href="/wow-a-link">wow a {{ linktext }}</a></li>
|
|
||||||
<li>1 + 1 = {{ 1 | plus: 1 }}</li>
|
|
||||||
<li>{% if true %}Yes!{% endif %}</li>
|
|
||||||
<li>foo = {% if foo %}true{%else%}false{% endif %}</li>
|
|
||||||
<li>{{ missing_var | default: 'fallback' }}</li>
|
|
||||||
</ul>
|
|
||||||
{% endsnippet %}
|
|
||||||
|
|
||||||
{% render main, arg: 'lsf', ... %}
|
|
||||||
{{ foo }}
|
|
||||||
|
|
||||||
{% snippet listitem %}
|
|
||||||
<li>{{ forloop.index }}: {{ emoji }}</li>
|
|
||||||
{% endsnippet %}
|
|
||||||
|
|
||||||
{% assign emojis = "🌼,🌳,🌸" | split: "," %}
|
|
||||||
<ul style="list-style-type: none; display: flex; gap: 1em;">
|
|
||||||
{%- render listitem for emojis as emoji -%}
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user