mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-13 16:00:41 -07:00
Compare commits
246
Commits
docs-update
..
leg_c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c6bc2b2a3 | ||
|
|
56d1913b37 | ||
|
|
2f6b67798e | ||
|
|
82c222ef0f | ||
|
|
2baee3de3e | ||
|
|
a96cfd1297 | ||
|
|
cf765ebed3 | ||
|
|
8d234098aa | ||
|
|
43b44c007a | ||
|
|
858cb62c4f | ||
|
|
80be33884e | ||
|
|
cd040dabd8 | ||
|
|
18b83a58bd | ||
|
|
6b64bfb53e | ||
|
|
6c2fde5eea | ||
|
|
ce76dbf8d9 | ||
|
|
661ff2ccdf | ||
|
|
9c183bea83 | ||
|
|
484fd18612 | ||
|
|
bf86459456 | ||
|
|
d2827c561b | ||
|
|
16c34595a4 | ||
|
|
6e091909ee | ||
|
|
d7cb39ccb3 | ||
|
|
f8d46804fd | ||
|
|
5c6de2d919 | ||
|
|
a8e9327f0b | ||
|
|
f5a20ff8e8 | ||
|
|
d0184555d9 | ||
|
|
6ebdded8f2 | ||
|
|
515b31158e | ||
|
|
40cc799f3d | ||
|
|
5ac91e0837 | ||
|
|
f6cb54fa59 | ||
|
|
1606b4b705 | ||
|
|
7cfd0f15d1 | ||
|
|
25ba54fc52 | ||
|
|
1aff63ff57 | ||
|
|
08fdcbbf65 | ||
|
|
2dba9ed0ea | ||
|
|
6d02d59fbd | ||
|
|
281e3ea9c8 | ||
|
|
b51b30fac1 | ||
|
|
84ed3d9964 | ||
|
|
c10f936d2a | ||
|
|
1ee342d83b | ||
|
|
0e3b522fe2 | ||
|
|
db07e2b67e | ||
|
|
b8d7b9aeda | ||
|
|
3d7c1c80a0 | ||
|
|
1b2d0198ea | ||
|
|
043d816460 | ||
|
|
974ea40cca | ||
|
|
d8b416187a | ||
|
|
58ad90677b | ||
|
|
2b04590d4b | ||
|
|
bce0033c65 | ||
|
|
01dea94671 | ||
|
|
1a1b4702d7 | ||
|
|
85d1dc0d07 | ||
|
|
0eafe7f2fd | ||
|
|
815e4e2b8d | ||
|
|
ef98715b12 | ||
|
|
c4d713b6bb | ||
|
|
975b17b529 | ||
|
|
745d875e79 | ||
|
|
c91cb8af6c | ||
|
|
bb73198b4f | ||
|
|
f0f2e56369 | ||
|
|
b816521563 | ||
|
|
4026f6c340 | ||
|
|
05a20c627d | ||
|
|
8e3f0c122e | ||
|
|
487b240404 | ||
|
|
f129ee33f2 | ||
|
|
cdf7f5b6a7 | ||
|
|
204d876187 | ||
|
|
8b5cf73ccc | ||
|
|
edebcaa603 | ||
|
|
6cf6d8b990 | ||
|
|
1379061398 | ||
|
|
4971b9e9bc | ||
|
|
da34d27258 | ||
|
|
cc7899aef5 | ||
|
|
0fc78a2dbb | ||
|
|
c401ffb9c3 | ||
|
|
2434c3d0e0 | ||
|
|
352f83a9d2 | ||
|
|
98c96ed86a | ||
|
|
410cce9740 | ||
|
|
a8ed72a036 | ||
|
|
4aaf750fa8 | ||
|
|
e5a3d67a32 | ||
|
|
fe25644726 | ||
|
|
c47eac1683 | ||
|
|
c10a40f1fa | ||
|
|
e4003a74a1 | ||
|
|
03065274d8 | ||
|
|
00afc9dd8a | ||
|
|
6bfdda9e17 | ||
|
|
00da0b6a42 | ||
|
|
39174ccee6 | ||
|
|
c7033ff4c8 | ||
|
|
f85bea2902 | ||
|
|
17922273e1 | ||
|
|
4087a94d88 | ||
|
|
1a4ff9547a | ||
|
|
888cbe8f09 | ||
|
|
2f11364417 | ||
|
|
74cdfc6718 | ||
|
|
d19213177a | ||
|
|
caf59940d3 | ||
|
|
8319d78c2e | ||
|
|
bc55c4d348 | ||
|
|
017f0dc342 | ||
|
|
ab556cbdd9 | ||
|
|
82e4904403 | ||
|
|
59a63e0fe5 | ||
|
|
aafb3ed9f2 | ||
|
|
935d3530af | ||
|
|
662b2983fe | ||
|
|
37a0fe213b | ||
|
|
7bbb4ff84f | ||
|
|
9926d86c91 | ||
|
|
9c49b8bbb2 | ||
|
|
f7ff9c81d3 | ||
|
|
a65c4f51bc | ||
|
|
a24049906b | ||
|
|
aa678302d6 | ||
|
|
6d0bb3303c | ||
|
|
4fec29f288 | ||
|
|
33ecb29d49 | ||
|
|
58e5820e7a | ||
|
|
bb035d96e1 | ||
|
|
3919ff6bc3 | ||
|
|
381b4f5268 | ||
|
|
97f18112b2 | ||
|
|
ca2fa587cf | ||
|
|
0526348cae | ||
|
|
a3fb7ba2b3 | ||
|
|
77cc0f2ed9 | ||
|
|
3d43efe2bc | ||
|
|
772233d881 | ||
|
|
90d1bc26d8 | ||
|
|
c00a650492 | ||
|
|
4819eb1a92 | ||
|
|
8579807d29 | ||
|
|
daf786fd28 | ||
|
|
101137045e | ||
|
|
8a0a8cfd99 | ||
|
|
8304a046c9 | ||
|
|
c72c84ea9b | ||
|
|
01145f872b | ||
|
|
5409814552 | ||
|
|
2d9331a234 | ||
|
|
c59cde9d17 | ||
|
|
29e140b655 | ||
|
|
a48332871a | ||
|
|
bd7f867759 | ||
|
|
8e4573a7bf | ||
|
|
5425679a96 | ||
|
|
6831eac902 | ||
|
|
13f98de7f3 | ||
|
|
e26f509277 | ||
|
|
0417c9e723 | ||
|
|
ffd48880e2 | ||
|
|
6b79f25c87 | ||
|
|
ff829e7996 | ||
|
|
d53a4e1834 | ||
|
|
5ff699bb8a | ||
|
|
d87500bfe3 | ||
|
|
fce8bcb1e7 | ||
|
|
97548d4f01 | ||
|
|
cbf8986745 | ||
|
|
11dc18bfdf | ||
|
|
f42ce88456 | ||
|
|
d1d6febfc1 | ||
|
|
0150067c40 | ||
|
|
2d0532e041 | ||
|
|
167825aa92 | ||
|
|
c792c29066 | ||
|
|
a4d7c80ce0 | ||
|
|
7ff4352de2 | ||
|
|
44f35c0990 | ||
|
|
a65bd76e72 | ||
|
|
8ac4d6a92a | ||
|
|
37e913f755 | ||
|
|
5e0ad75ff5 | ||
|
|
1b3b3e4958 | ||
|
|
31a5606d42 | ||
|
|
f65ce254c7 | ||
|
|
01c25a11a3 | ||
|
|
f29b9335c5 | ||
|
|
cfe3e6f3be | ||
|
|
09c0b3b391 | ||
|
|
678fdfdb8a | ||
|
|
ed1b542abf | ||
|
|
8d27864845 | ||
|
|
37580976db | ||
|
|
daadb1a2d6 | ||
|
|
68433a52a3 | ||
|
|
075341d01c | ||
|
|
981831bc49 | ||
|
|
edcc14f148 | ||
|
|
e3fd003a74 | ||
|
|
26faf512a1 | ||
|
|
56f1aa9b4a | ||
|
|
70ca647e1e | ||
|
|
13ddc6d96b | ||
|
|
88309cf415 | ||
|
|
7b9b5f31fb | ||
|
|
b165599495 | ||
|
|
96c998a944 | ||
|
|
7031d8a49a | ||
|
|
7959664c9d | ||
|
|
c15a683063 | ||
|
|
36860eab57 | ||
|
|
3d8efe04a7 | ||
|
|
edf7b5577b | ||
|
|
282786d7e2 | ||
|
|
69bc84b777 | ||
|
|
3bfde37a53 | ||
|
|
24bf446b0e | ||
|
|
916f501bde | ||
|
|
7eeb895192 | ||
|
|
7acdac2a1c | ||
|
|
50edd0f5b9 | ||
|
|
819b70204f | ||
|
|
eb609ee4aa | ||
|
|
3eddf5fb9e | ||
|
|
6dd4f716f8 | ||
|
|
5c259a3f49 | ||
|
|
1a160c5d84 | ||
|
|
56caba720d | ||
|
|
d28cbe6df7 | ||
|
|
1ccb83d7cb | ||
|
|
e0dd07811c | ||
|
|
82e5e8c188 | ||
|
|
3ef9d2f4f9 | ||
|
|
4c30922d8e | ||
|
|
ed75a6d948 | ||
|
|
63f9a05223 | ||
|
|
8f45647aa3 | ||
|
|
4c0cfae0b7 | ||
|
|
7f58cbf82d | ||
|
|
1d647361e1 |
+8
-39
@@ -1,41 +1,10 @@
|
||||
_site/
|
||||
.sass-cache/
|
||||
node_modules/
|
||||
|
||||
# Compiled source #
|
||||
###################
|
||||
*.com
|
||||
*.class
|
||||
*.dll
|
||||
*.exe
|
||||
*~
|
||||
*.gem
|
||||
*.swp
|
||||
pkg
|
||||
*.rbc
|
||||
.rvmrc
|
||||
*.o
|
||||
*.so
|
||||
*.bundle
|
||||
ext/liquid/Makefile
|
||||
|
||||
# Packages #
|
||||
############
|
||||
# it's better to unpack these files and commit the raw source
|
||||
# git has its own built in compression methods
|
||||
*.7z
|
||||
*.dmg
|
||||
*.gz
|
||||
*.iso
|
||||
*.jar
|
||||
*.rar
|
||||
*.tar
|
||||
*.zip
|
||||
|
||||
# Logs and databases #
|
||||
######################
|
||||
*.log
|
||||
*.sql
|
||||
*.sqlite
|
||||
|
||||
# OS generated files #
|
||||
######################
|
||||
.DS_Store
|
||||
.DS_Store?
|
||||
._*
|
||||
.Spotlight-V100
|
||||
.Trashes
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
+13
-4
@@ -1,4 +1,13 @@
|
||||
install: gem install github-pages
|
||||
script: jekyll build --trace
|
||||
sudo: false
|
||||
rvm: 2.1
|
||||
rvm:
|
||||
- 1.8.7
|
||||
- 1.9.3
|
||||
- ree
|
||||
- jruby-18mode
|
||||
- jruby-19mode
|
||||
- rbx-18mode
|
||||
- rbx-19mode
|
||||
|
||||
script: "rake test"
|
||||
|
||||
notifications:
|
||||
disable: true
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'github-pages', group: :jekyll_plugins
|
||||
-133
@@ -1,133 +0,0 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
RedCloth (4.2.9)
|
||||
activesupport (4.2.6)
|
||||
i18n (~> 0.7)
|
||||
json (~> 1.7, >= 1.7.7)
|
||||
minitest (~> 5.1)
|
||||
thread_safe (~> 0.3, >= 0.3.4)
|
||||
tzinfo (~> 1.1)
|
||||
addressable (2.4.0)
|
||||
coffee-script (2.4.1)
|
||||
coffee-script-source
|
||||
execjs
|
||||
coffee-script-source (1.10.0)
|
||||
colorator (0.1)
|
||||
ethon (0.8.1)
|
||||
ffi (>= 1.3.0)
|
||||
execjs (2.6.0)
|
||||
faraday (0.9.2)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
ffi (1.9.10)
|
||||
gemoji (2.1.0)
|
||||
github-pages (64)
|
||||
RedCloth (= 4.2.9)
|
||||
github-pages-health-check (= 1.1.0)
|
||||
jekyll (= 3.0.3)
|
||||
jekyll-coffeescript (= 1.0.1)
|
||||
jekyll-feed (= 0.4.0)
|
||||
jekyll-gist (= 1.4.0)
|
||||
jekyll-github-metadata (= 1.9.0)
|
||||
jekyll-mentions (= 1.0.1)
|
||||
jekyll-paginate (= 1.1.0)
|
||||
jekyll-redirect-from (= 0.10.0)
|
||||
jekyll-sass-converter (= 1.3.0)
|
||||
jekyll-seo-tag (= 1.3.2)
|
||||
jekyll-sitemap (= 0.10.0)
|
||||
jekyll-textile-converter (= 0.1.0)
|
||||
jemoji (= 0.5.1)
|
||||
kramdown (= 1.10.0)
|
||||
liquid (= 3.0.6)
|
||||
mercenary (~> 0.3)
|
||||
rdiscount (= 2.1.8)
|
||||
redcarpet (= 3.3.3)
|
||||
rouge (= 1.10.1)
|
||||
terminal-table (~> 1.4)
|
||||
github-pages-health-check (1.1.0)
|
||||
addressable (~> 2.3)
|
||||
net-dns (~> 0.8)
|
||||
octokit (~> 4.0)
|
||||
public_suffix (~> 1.4)
|
||||
typhoeus (~> 0.7)
|
||||
html-pipeline (2.3.0)
|
||||
activesupport (>= 2, < 5)
|
||||
nokogiri (>= 1.4)
|
||||
i18n (0.7.0)
|
||||
jekyll (3.0.3)
|
||||
colorator (~> 0.1)
|
||||
jekyll-sass-converter (~> 1.0)
|
||||
jekyll-watch (~> 1.1)
|
||||
kramdown (~> 1.3)
|
||||
liquid (~> 3.0)
|
||||
mercenary (~> 0.3.3)
|
||||
rouge (~> 1.7)
|
||||
safe_yaml (~> 1.0)
|
||||
jekyll-coffeescript (1.0.1)
|
||||
coffee-script (~> 2.2)
|
||||
jekyll-feed (0.4.0)
|
||||
jekyll-gist (1.4.0)
|
||||
octokit (~> 4.2)
|
||||
jekyll-github-metadata (1.9.0)
|
||||
octokit (~> 4.0)
|
||||
jekyll-mentions (1.0.1)
|
||||
html-pipeline (~> 2.3)
|
||||
jekyll (~> 3.0)
|
||||
jekyll-paginate (1.1.0)
|
||||
jekyll-redirect-from (0.10.0)
|
||||
jekyll (>= 2.0)
|
||||
jekyll-sass-converter (1.3.0)
|
||||
sass (~> 3.2)
|
||||
jekyll-seo-tag (1.3.2)
|
||||
jekyll (~> 3.0)
|
||||
jekyll-sitemap (0.10.0)
|
||||
jekyll-textile-converter (0.1.0)
|
||||
RedCloth (~> 4.0)
|
||||
jekyll-watch (1.3.1)
|
||||
listen (~> 3.0)
|
||||
jemoji (0.5.1)
|
||||
gemoji (~> 2.0)
|
||||
html-pipeline (~> 2.2)
|
||||
jekyll (>= 2.0)
|
||||
json (1.8.3)
|
||||
kramdown (1.10.0)
|
||||
liquid (3.0.6)
|
||||
listen (3.0.6)
|
||||
rb-fsevent (>= 0.9.3)
|
||||
rb-inotify (>= 0.9.7)
|
||||
mercenary (0.3.5)
|
||||
mini_portile2 (2.0.0)
|
||||
minitest (5.8.4)
|
||||
multipart-post (2.0.0)
|
||||
net-dns (0.8.0)
|
||||
nokogiri (1.6.7.2)
|
||||
mini_portile2 (~> 2.0.0.rc2)
|
||||
octokit (4.3.0)
|
||||
sawyer (~> 0.7.0, >= 0.5.3)
|
||||
public_suffix (1.5.3)
|
||||
rb-fsevent (0.9.7)
|
||||
rb-inotify (0.9.7)
|
||||
ffi (>= 0.5.0)
|
||||
rdiscount (2.1.8)
|
||||
redcarpet (3.3.3)
|
||||
rouge (1.10.1)
|
||||
safe_yaml (1.0.4)
|
||||
sass (3.4.21)
|
||||
sawyer (0.7.0)
|
||||
addressable (>= 2.3.5, < 2.5)
|
||||
faraday (~> 0.8, < 0.10)
|
||||
terminal-table (1.5.2)
|
||||
thread_safe (0.3.5)
|
||||
typhoeus (0.8.0)
|
||||
ethon (>= 0.8.0)
|
||||
tzinfo (1.2.2)
|
||||
thread_safe (~> 0.1)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
github-pages
|
||||
|
||||
BUNDLED WITH
|
||||
1.11.2
|
||||
@@ -1,72 +0,0 @@
|
||||
// Gruntfile
|
||||
module.exports = function(grunt) {
|
||||
require('load-grunt-tasks')(grunt);
|
||||
|
||||
// Project configuration.
|
||||
grunt.initConfig({
|
||||
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
|
||||
watch: {
|
||||
css: {
|
||||
files: ['_sass/**/*.scss'],
|
||||
tasks: ['sass', 'postcss', 'shell:jekyllBuild'],
|
||||
options: {
|
||||
atBegin: true
|
||||
}
|
||||
},
|
||||
jekyll: {
|
||||
files: ['index.md', '_includes/*.html', 'filters/*.*', '_layouts/*.*', 'tags/*.*', 'basics/*.*'],
|
||||
tasks: ['shell:jekyllBuild']
|
||||
}
|
||||
},
|
||||
|
||||
sass: {
|
||||
dist: {
|
||||
options: {
|
||||
style: 'expanded',
|
||||
sourcemap: 'none'
|
||||
},
|
||||
files: {
|
||||
'_site/css/main.css':'_sass/main.scss'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
shell: {
|
||||
jekyllServe: {
|
||||
command: 'jekyll serve --no-watch'
|
||||
},
|
||||
|
||||
jekyllBuild: {
|
||||
command: 'jekyll build'
|
||||
}
|
||||
},
|
||||
|
||||
postcss: {
|
||||
options: {
|
||||
map: true,
|
||||
processors: [
|
||||
require('autoprefixer-core')({browsers: 'last 2 versions'})
|
||||
]
|
||||
},
|
||||
dist: {
|
||||
src: '_site/css/*.css'
|
||||
}
|
||||
},
|
||||
|
||||
concurrent: {
|
||||
tasks: ['shell:jekyllServe', 'watch'],
|
||||
options: {
|
||||
logConcurrentOutput: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
grunt.loadNpmTasks('grunt-contrib-watch');
|
||||
grunt.loadNpmTasks('grunt-contrib-sass');
|
||||
grunt.loadNpmTasks('grunt-postcss');
|
||||
grunt.loadNpmTasks('grunt-concurrent');
|
||||
|
||||
grunt.registerTask('default', ['concurrent']);
|
||||
};
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
# Liquid Version History
|
||||
|
||||
## 2.4.0 / 2012-08-03
|
||||
|
||||
* Performance improvements
|
||||
* Allow filters in `assign`
|
||||
* Add `modulo` filter
|
||||
* Ruby 1.8, 1.9, and Rubinius compatibility fixes
|
||||
* Add support for `quoted['references']` in `tablerow`
|
||||
* Add support for Enumerable to `tablerow`
|
||||
* `strip_html` filter removes html comments
|
||||
|
||||
|
||||
## 2.3.0 / 2011-10-16
|
||||
|
||||
* Several speed/memory improvements
|
||||
* Numerous bug fixes
|
||||
* Added support for MRI 1.9, Rubinius, and JRuby
|
||||
* Added support for integer drop parameters
|
||||
* Added epoch support to `date` filter
|
||||
* New `raw` tag that suppresses parsing
|
||||
* Added `else` option to `for` tag
|
||||
* New `increment` tag
|
||||
* New `split` filter
|
||||
|
||||
|
||||
## 2.2.1 / 2010-08-23
|
||||
|
||||
* Added support for literal tags
|
||||
|
||||
|
||||
## 2.2.0 / 2010-08-22
|
||||
|
||||
* Compatible with Ruby 1.8.7, 1.9.1 and 1.9.2-p0
|
||||
* Merged some changed made by the community
|
||||
|
||||
|
||||
## 1.9.0 / 2008-03-04
|
||||
|
||||
* Fixed gem install rake task
|
||||
* Improve Error encapsulation in liquid by maintaining a own set of exceptions instead of relying on ruby build ins
|
||||
|
||||
|
||||
## Before 1.9.0
|
||||
|
||||
* Added If with or / and expressions
|
||||
* Implemented .to_liquid for all objects which can be passed to liquid like Strings Arrays Hashes Numerics and Booleans. To export new objects to liquid just implement .to_liquid on them and return objects which themselves have .to_liquid methods.
|
||||
* Added more tags to standard library
|
||||
* Added include tag ( like partials in rails )
|
||||
* [...] Gazillion of detail improvements
|
||||
* Added strainers as filter hosts for better security [Tobias Luetke]
|
||||
* Fixed that rails integration would call filter with the wrong "self" [Michael Geary]
|
||||
* Fixed bad error reporting when a filter called a method which doesn't exist. Liquid told you that it couldn't find the filter which was obviously misleading [Tobias Luetke]
|
||||
* Removed count helper from standard lib. use size [Tobias Luetke]
|
||||
* Fixed bug with string filter parameters failing to tolerate commas in strings. [Paul Hammond]
|
||||
* Improved filter parameters. Filter parameters are now context sensitive; Types are resolved according to the rules of the context. Multiple parameters are now separated by the Liquid::ArgumentSeparator: , by default [Paul Hammond]
|
||||
{{ 'Typo' | link_to: 'http://typo.leetsoft.com', 'Typo - a modern weblog engine' }}
|
||||
* Added Liquid::Drop. A base class which you can use for exporting proxy objects to liquid which can acquire more data when used in liquid. [Tobias Luetke]
|
||||
|
||||
class ProductDrop < Liquid::Drop
|
||||
def top_sales
|
||||
Shop.current.products.find(:all, :order => 'sales', :limit => 10 )
|
||||
end
|
||||
end
|
||||
t = Liquid::Template.parse( ' {% for product in product.top_sales %} {{ product.name }} {% endfor %} ' )
|
||||
t.render('product' => ProductDrop.new )
|
||||
* Added filter parameters support. Example: {{ date | format_date: "%Y" }} [Paul Hammond]
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
Copyright (c) 2005, 2006 Tobias Luetke
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -1,9 +1,44 @@
|
||||
# New Liquid Docs
|
||||
# Liquid template engine
|
||||
|
||||
To run, follow these steps:
|
||||
## Introduction
|
||||
|
||||
1. Download ZIP or clone in GitHub
|
||||
2. Navigate to `liquid` folder
|
||||
3. Run `jekyll watch`
|
||||
4. Open `http://127.0.0.1:4000` in your browser
|
||||
Liquid is a template engine which was written with very specific requirements:
|
||||
|
||||
* It has to have beautiful and simple markup. Template engines which don't produce good looking markup are no fun to use.
|
||||
* It needs to be non evaling and secure. Liquid templates are made so that users can edit them. You don't want to run code on your server which your users wrote.
|
||||
* It has to be stateless. Compile and render steps have to be separate so that the expensive parsing and compiling can be done once and later on you can just render it passing in a hash with local variables and objects.
|
||||
|
||||
## Why you should use Liquid
|
||||
|
||||
* You want to allow your users to edit the appearance of your application but don't want them to run **insecure code on your server**.
|
||||
* You want to render templates directly from the database.
|
||||
* You like smarty (PHP) style template engines.
|
||||
* You need a template engine which does HTML just as well as emails.
|
||||
* You don't like the markup of your current templating engine.
|
||||
|
||||
## What does it look like?
|
||||
|
||||
```html
|
||||
<ul id="products">
|
||||
{% for product in products %}
|
||||
<li>
|
||||
<h2>{{ product.name }}</h2>
|
||||
Only {{ product.price | price }}
|
||||
|
||||
{{ product.description | prettyprint | paragraph }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
```
|
||||
|
||||
## How to use Liquid
|
||||
|
||||
Liquid supports a very simple API based around the Liquid::Template class.
|
||||
For standard use you can just pass it the content of a file and call render with a parameters hash.
|
||||
|
||||
```ruby
|
||||
@template = Liquid::Template.parse("hi {{name}}") # Parses and compiles the template
|
||||
@template.render('name' => 'tobi') # => "hi tobi"
|
||||
```
|
||||
|
||||
[](http://travis-ci.org/Shopify/liquid)
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
require 'rubygems'
|
||||
require 'rake'
|
||||
require 'rake/clean'
|
||||
require 'fileutils'
|
||||
require 'rake/testtask'
|
||||
require 'rubygems/package_task'
|
||||
|
||||
task :default => [:compile, :test]
|
||||
|
||||
task :gen do
|
||||
sh "leg -oext/liquid/liquid_context.c ext/liquid/liquid_context.leg"
|
||||
end
|
||||
|
||||
task :compile => [:gen, :liquid_ext]
|
||||
|
||||
extension = "liquid_ext"
|
||||
ext = "ext/liquid"
|
||||
ext_so = "#{ext}/#{extension}.#{RbConfig::CONFIG['DLEXT']}"
|
||||
ext_files = FileList[
|
||||
"#{ext}/*.c",
|
||||
"#{ext}/*.h",
|
||||
"#{ext}/*.leg",
|
||||
"#{ext}/extconf.rb",
|
||||
"#{ext}/Makefile",
|
||||
"lib"
|
||||
]
|
||||
|
||||
task "lib" do
|
||||
directory "lib"
|
||||
end
|
||||
|
||||
desc "Builds just the #{extension} extension"
|
||||
task extension.to_sym => [:gen, "#{ext}/Makefile", ext_so ]
|
||||
|
||||
file "#{ext}/Makefile" => ["#{ext}/extconf.rb"] do
|
||||
Dir.chdir(ext) do ruby "extconf.rb" end
|
||||
end
|
||||
|
||||
file ext_so => ext_files do
|
||||
Dir.chdir(ext) do
|
||||
sh "make"
|
||||
end
|
||||
cp ext_so, "lib"
|
||||
end
|
||||
|
||||
Rake::TestTask.new(:test => [:gen, 'liquid_ext']) do |t|
|
||||
t.libs << '.' << 'lib' << 'test'
|
||||
t.test_files = FileList['test/liquid/**/*_test.rb']
|
||||
t.verbose = false
|
||||
end
|
||||
|
||||
gemspec = eval(File.read('liquid.gemspec'))
|
||||
Gem::PackageTask.new(gemspec) do |pkg|
|
||||
pkg.gem_spec = gemspec
|
||||
end
|
||||
|
||||
desc "Build the gem and release it to rubygems.org"
|
||||
task :release => :gem do
|
||||
sh "gem push pkg/liquid-#{gemspec.version}.gem"
|
||||
end
|
||||
|
||||
namespace :benchmark do
|
||||
|
||||
desc "Run the liquid benchmark"
|
||||
task :run do
|
||||
ruby "./performance/benchmark.rb"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
namespace :profile do
|
||||
|
||||
desc "Run the liquid profile/performance coverage"
|
||||
task :run do
|
||||
ruby "./performance/profile.rb"
|
||||
end
|
||||
|
||||
desc "Run KCacheGrind"
|
||||
task :grind => :run do
|
||||
system "qcachegrind /tmp//callgrind.liquid.txt"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
desc "Run example"
|
||||
task :example do
|
||||
ruby "-w -d -Ilib example/server/server.rb"
|
||||
end
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
title: Liquid Templating Engine
|
||||
description: "Liquid is a template language and accompanying rendering engine. It is built for security, so is perfect for rendering custom templates from your users."
|
||||
|
||||
repository: https://github.com/Shopify/liquid
|
||||
|
||||
# Build settings
|
||||
baseurl: "" # the subpath of your site, e.g. /blog/
|
||||
url: http://liquidmarkup.org # the base hostname & protocol for your site
|
||||
markdown: redcarpet
|
||||
redcarpet:
|
||||
extensions: ["with_toc_data", "tables", "disable_indented_code_blocks", "no_intra_emphasis"]
|
||||
highlighter: pygments
|
||||
permalink: pretty
|
||||
exclude:
|
||||
- README.md
|
||||
- CNAME
|
||||
- node_modules
|
||||
keep_files: ["css"]
|
||||
|
||||
# Front matter defaults
|
||||
defaults:
|
||||
- scope:
|
||||
path: "" # an empty string here means all files in the project
|
||||
values:
|
||||
layout: default
|
||||
@@ -1,8 +0,0 @@
|
||||
<header class="home-banner">
|
||||
<h1>Liquid</h1>
|
||||
<p>Safe, customer facing template language for flexible web apps.</p>
|
||||
<p class="btn-row">
|
||||
<a href="https://github.com/Shopify/liquid/archive/master.zip" target="_blank" class="btn"><i class="icon fa fa-2x fa-arrow-circle-down"></i>Download</a>
|
||||
<a href="https://github.com/Shopify/liquid" target="_blank" class="btn"><i class="icon fa fa-2x fa-github"></i>View on Github</a>
|
||||
</p>
|
||||
</header>
|
||||
@@ -1,24 +0,0 @@
|
||||
<div class="home-users-grid">
|
||||
<div class="home-users-grid__item">
|
||||
<a href="http://jekyllrb.com/" target="_blank">
|
||||
<img src="/images/jekyll-logo.png" />
|
||||
</a>
|
||||
</div>
|
||||
<div class="home-users-grid__item">
|
||||
<a href="http://www.desk.com/" target="_blank">
|
||||
<img src="/images/salesforcedesk-logo.png" />
|
||||
</a>
|
||||
</div>
|
||||
<div class="home-users-grid__item">
|
||||
<a href="https://www.zendesk.com/ " target="_blank">
|
||||
<img src="/images/zendesk-logo.png" />
|
||||
</a>
|
||||
</div>
|
||||
<div class="home-users-grid__item">
|
||||
<a href="http://500px.com/" target="_blank">
|
||||
<img src="/images/500px-logo.png" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="home-users-blurb">...and <a href="https://github.com/Shopify/liquid/wiki#who-uses-liquid" target="_blank">many more!</a></p>
|
||||
@@ -1,18 +0,0 @@
|
||||
<div class="sidebar">
|
||||
<div class="sidebar--logo">
|
||||
<a href="/">Liquid</a>
|
||||
</div>
|
||||
<nav class="sidebar--nav"> {% assign sections = "basics, tags, filters" | split: ", " %}
|
||||
|
||||
{% for section in sections %}
|
||||
<h3 class="section__header">{{ section | capitalize }}</h3>
|
||||
|
||||
<ul class="section__links">
|
||||
{% for item in site.pages %}{% if item.url contains section/ %}{% unless item.path contains "index" %}
|
||||
<li><a href="{{ item.url | prepend: site.baseurl }}" class="section__link{% if item.url contains page.url and page.url != "/" %} section__link--is-active {% endif %}">{{ item.title }}</a></li>
|
||||
{% endunless %}{% endif %}{% endfor %}
|
||||
</ul>
|
||||
{% endfor %}
|
||||
|
||||
</nav>
|
||||
</div>
|
||||
@@ -1,29 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>{% if page.title %}{{ page.title }} – {% endif %}{{ site.title }}</title>
|
||||
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="description" content="{% if page.excerpt %}{{ page.excerpt | strip_html | strip_newlines | truncate: 160 }}{% else %}{{ site.description }}{% endif %}">
|
||||
|
||||
<link rel="stylesheet" href="{{ '/css/main.css' | prepend: site.baseurl }}">
|
||||
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css'>
|
||||
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
|
||||
<link rel="canonical" href="{{ page.url | replace:'index.html','' | prepend: site.baseurl | prepend: site.url }}">
|
||||
<link rel="alternate" type="application/rss+xml" title="{{ site.title }}" href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url }}" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
{% include sidebar.html %}
|
||||
|
||||
<div class="content__area">
|
||||
<div class="content">
|
||||
<h1>{{ page.title }}</h1>
|
||||
{{ content }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,17 +0,0 @@
|
||||
|
||||
@charset "utf-8";
|
||||
|
||||
@import "partials/defaults";
|
||||
@import "partials/colors";
|
||||
@import "partials/helpers";
|
||||
|
||||
@import "modules/base";
|
||||
@import "modules/layout";
|
||||
@import "modules/buttons";
|
||||
@import "modules/home-banner";
|
||||
@import "modules/home-users-grid";
|
||||
@import "modules/content-area";
|
||||
|
||||
@import "vendors/syntax-highlighting";
|
||||
|
||||
|
||||
@@ -1,185 +0,0 @@
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset some basic elements
|
||||
*/
|
||||
body, h1, h2, h3, h4, h5, h6,
|
||||
p, blockquote, pre, hr,
|
||||
dl, dd, ol, ul, figure {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic styling
|
||||
*/
|
||||
body {
|
||||
font-family: $base-font-family;
|
||||
font-size: $base-font-size;
|
||||
line-height: $base-line-height;
|
||||
font-weight: 300;
|
||||
color: $color-slate;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
}
|
||||
|
||||
/** Set `margin-bottom` to maintain vertical rhythm */
|
||||
|
||||
h1, h2, h3, h4, h5, h6,
|
||||
p, blockquote, pre,
|
||||
ul, ol, dl, figure,
|
||||
%vertical-rhythm {
|
||||
margin-bottom: $spacing-unit / 2;
|
||||
}
|
||||
|
||||
/** Images */
|
||||
|
||||
img {
|
||||
max-width: 100%;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/** Figures */
|
||||
|
||||
figure > img {
|
||||
display: block;
|
||||
}
|
||||
|
||||
figcaption {
|
||||
font-size: $small-font-size;
|
||||
}
|
||||
|
||||
/** Lists */
|
||||
ul, ol {
|
||||
margin-left: $spacing-unit;
|
||||
}
|
||||
|
||||
li {
|
||||
> ul, > ol {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** Headings */
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/** Links */
|
||||
a {
|
||||
color: $color-blue-5;
|
||||
|
||||
&:visited {
|
||||
color: #609;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
font-size: 1.5em;
|
||||
text-decoration: underline;
|
||||
margin-top: $spacing-unit;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 1em;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
h4 {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
color: lighten($color-slate, 30%);
|
||||
border-left: 2px solid lighten($color-slate, 50%);
|
||||
padding-left: $spacing-unit / 2;
|
||||
letter-spacing: -1px;
|
||||
font-style: italic;
|
||||
|
||||
> :last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
pre, code {
|
||||
font-size: 15px;
|
||||
border-radius: 3px;
|
||||
background-color: lighten($color-blue-1, 0.9);
|
||||
}
|
||||
|
||||
code {
|
||||
padding: 1px 5px;
|
||||
}
|
||||
|
||||
pre {
|
||||
padding: 8px 12px;
|
||||
border: 1px solid $color-blue-2;
|
||||
word-wrap: break-word;
|
||||
|
||||
> code {
|
||||
border: 0;
|
||||
padding-right: 0;
|
||||
padding-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
hr {
|
||||
display: block;
|
||||
height: 1px;
|
||||
border: 0;
|
||||
background-color: lighten($color-slate, 50%);
|
||||
margin-bottom: $spacing-unit/2;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
overflow: auto;
|
||||
display: block;
|
||||
margin: 15px 0;
|
||||
border-collapse: collapse;
|
||||
thead {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
font-size: 100%;
|
||||
font: inherit;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
th {
|
||||
border: 1px solid #ddd;
|
||||
padding: 6px 13px;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
}
|
||||
tbody {
|
||||
vertical-align: middle;
|
||||
border-color: inherit;
|
||||
}
|
||||
tr {
|
||||
border-top: 1px solid #ccc;
|
||||
background-color: #fff;
|
||||
vertical-align: inherit;
|
||||
}
|
||||
td {
|
||||
border: 1px solid #ddd;
|
||||
padding: 6px 13px;
|
||||
}
|
||||
/* Don't use a margin on code samples within tables */
|
||||
pre {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
p {
|
||||
line-height: 1.8;
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
.btn {
|
||||
color: $color-white;
|
||||
display: flex;
|
||||
background: $color-blue-5;
|
||||
align-items: center;
|
||||
padding: $spacing-unit/4 $spacing-unit/2;
|
||||
border-radius: 8px;
|
||||
text-decoration: none;
|
||||
|
||||
&:hover {
|
||||
background: $color-blue-4;
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
|
||||
.btn:visited {
|
||||
color: $color-white;
|
||||
}
|
||||
|
||||
.btn-row {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin-bottom: 0;
|
||||
|
||||
.btn:not(:first-child) {
|
||||
margin-left: $spacing-unit / 2;
|
||||
}
|
||||
}
|
||||
|
||||
.icon {
|
||||
vertical-align: middle;
|
||||
margin-right: $spacing-unit / 4;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
.content__item {
|
||||
margin-bottom: $spacing-unit * 2;
|
||||
}
|
||||
|
||||
.highlight {
|
||||
|
||||
pre {
|
||||
border-top: none;
|
||||
border-radius: 0 0 3px 3px;
|
||||
}
|
||||
|
||||
&:before {
|
||||
content: "Example";
|
||||
display: block;
|
||||
padding: 8px 12px;
|
||||
color: $color-slate;
|
||||
background: #fff;
|
||||
border: 1px solid $color-blue-2;
|
||||
border-radius: 3px 3px 0 0;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
// Label every second code block with "Output"
|
||||
& + .highlight:nth-of-type(2n) {
|
||||
&:before {
|
||||
content: "Output";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
.home-banner {
|
||||
text-align: center;
|
||||
border-bottom: 1px solid lighten($color-slate, 50%);
|
||||
padding-bottom: $spacing-unit;
|
||||
margin-bottom: $spacing-unit;
|
||||
|
||||
h1 {
|
||||
font-weight: bold;
|
||||
font-size: 5em;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
.home-users-grid {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: $spacing-unit / 2;
|
||||
}
|
||||
|
||||
.home-users-grid__item{
|
||||
flex: 1;
|
||||
margin-right: $spacing-unit / 2;
|
||||
max-width: 50%;
|
||||
|
||||
&:last-child {
|
||||
margin-right: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.home-users-blurb {
|
||||
text-align: right;
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
|
||||
$sidebar-width: 250px;
|
||||
$logo-height: 130px;
|
||||
$wrapper-width: 800px;
|
||||
|
||||
/*============================================================================
|
||||
Content Area
|
||||
==============================================================================*/
|
||||
|
||||
.content__area {
|
||||
padding: $spacing-unit $spacing-unit $spacing-unit ($spacing-unit + $sidebar-width);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.content {
|
||||
max-width: $wrapper-width;
|
||||
margin: 0 auto;
|
||||
padding: 0 $spacing-unit;
|
||||
@extend %clearfix;
|
||||
}
|
||||
|
||||
/*============================================================================
|
||||
Sidebar
|
||||
==============================================================================*/
|
||||
|
||||
.sidebar {
|
||||
background: $color-blue-5;
|
||||
width: $sidebar-width;
|
||||
height: 100vh;
|
||||
position: fixed;
|
||||
}
|
||||
|
||||
.sidebar--logo {
|
||||
font-size: $base-font-size * 2;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
height: $logo-height;
|
||||
line-height: $logo-height;
|
||||
margin-bottom: 0;
|
||||
border-bottom: 1px solid $color-blue-4;
|
||||
|
||||
a {
|
||||
color: $color-white;
|
||||
text-decoration: none;
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar--nav {
|
||||
padding: $spacing-unit $spacing-unit ($spacing-unit + $logo-height); // Add a bit more padding at the bottom for consistency.
|
||||
font-weight: bold;
|
||||
max-height: 100%;
|
||||
overflow-y: scroll;
|
||||
|
||||
li {
|
||||
list-style: none;
|
||||
|
||||
a {
|
||||
color: $color-white;
|
||||
|
||||
&:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.section {
|
||||
margin: 0px;
|
||||
|
||||
> li {
|
||||
margin-bottom: $spacing-unit / 2;
|
||||
|
||||
&:last-child {
|
||||
margin-bottom: $spacing-unit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.section__header {
|
||||
font-weight: bold;
|
||||
font-size: 1em;
|
||||
text-decoration: none;
|
||||
color: $color-white;
|
||||
margin-bottom: $spacing-unit / 4;
|
||||
}
|
||||
|
||||
.section__links {
|
||||
margin-left: $spacing-unit / 2;
|
||||
margin-bottom: $spacing-unit;
|
||||
font-weight: normal;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
.section__link {
|
||||
display: inline-block;
|
||||
margin-top: $spacing-unit/4;
|
||||
opacity: 0.75;
|
||||
text-decoration: none;
|
||||
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
.section__link--is-active {
|
||||
font-weight: bold;
|
||||
opacity: 1;
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
// I got the blues, man.
|
||||
// 1 --> 5, lightest --> darkest.
|
||||
|
||||
$color-blue-1: #E8F8FF;
|
||||
$color-blue-2: #B4DCED;
|
||||
$color-blue-3: #91C9E8;
|
||||
$color-blue-4: #67B8DE;
|
||||
$color-blue-5: #3399CC;
|
||||
$color-white: #ffffff;
|
||||
$color-slate: #5E5E5E;
|
||||
@@ -1,6 +0,0 @@
|
||||
$base-font-family: 'Droid Sans', sans-serif;
|
||||
$base-font-size: 18px;
|
||||
$small-font-size: $base-font-size * 0.875;
|
||||
$base-line-height: 1.5;
|
||||
$spacing-unit: 40px;
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
%clearfix {
|
||||
&:after {
|
||||
content: "";
|
||||
display: table;
|
||||
clear: both;
|
||||
}
|
||||
}
|
||||
-67
@@ -1,67 +0,0 @@
|
||||
/**
|
||||
* Syntax highlighting styles
|
||||
*/
|
||||
.highlight {
|
||||
background: #fff;
|
||||
@extend %vertical-rhythm;
|
||||
|
||||
.c { color: #998; font-style: italic } // Comment
|
||||
.err { color: #a61717; background-color: #e3d2d2 } // Error
|
||||
.k { font-weight: bold } // Keyword
|
||||
.o { font-weight: bold } // Operator
|
||||
.cm { color: #998; font-style: italic } // Comment.Multiline
|
||||
.cp { color: #999; font-weight: bold } // Comment.Preproc
|
||||
.c1 { color: #998; font-style: italic } // Comment.Single
|
||||
.cs { color: #999; font-weight: bold; font-style: italic } // Comment.Special
|
||||
.gd { color: #000; background-color: #fdd } // Generic.Deleted
|
||||
.gd .x { color: #000; background-color: #faa } // Generic.Deleted.Specific
|
||||
.ge { font-style: italic } // Generic.Emph
|
||||
.gr { color: #a00 } // Generic.Error
|
||||
.gh { color: #999 } // Generic.Heading
|
||||
.gi { color: #000; background-color: #dfd } // Generic.Inserted
|
||||
.gi .x { color: #000; background-color: #afa } // Generic.Inserted.Specific
|
||||
.go { color: #888 } // Generic.Output
|
||||
.gp { color: #555 } // Generic.Prompt
|
||||
.gs { font-weight: bold } // Generic.Strong
|
||||
.gu { color: #aaa } // Generic.Subheading
|
||||
.gt { color: #a00 } // Generic.Traceback
|
||||
.kc { font-weight: bold } // Keyword.Constant
|
||||
.kd { font-weight: bold } // Keyword.Declaration
|
||||
.kp { font-weight: bold } // Keyword.Pseudo
|
||||
.kr { font-weight: bold } // Keyword.Reserved
|
||||
.kt { color: #458; font-weight: bold } // Keyword.Type
|
||||
.m { color: #099 } // Literal.Number
|
||||
.s { color: #d14 } // Literal.String
|
||||
.na { color: #008080 } // Name.Attribute
|
||||
.nb { color: #0086B3 } // Name.Builtin
|
||||
.nc { color: #458; font-weight: bold } // Name.Class
|
||||
.no { color: #008080 } // Name.Constant
|
||||
.ni { color: #800080 } // Name.Entity
|
||||
.ne { color: #900; font-weight: bold } // Name.Exception
|
||||
.nf { color: #900; font-weight: bold } // Name.Function
|
||||
.nn { color: #555 } // Name.Namespace
|
||||
.nt { color: #000080 } // Name.Tag
|
||||
.nv { color: #008080 } // Name.Variable
|
||||
.ow { font-weight: bold } // Operator.Word
|
||||
.w { color: #bbb } // Text.Whitespace
|
||||
.mf { color: #099 } // Literal.Number.Float
|
||||
.mh { color: #099 } // Literal.Number.Hex
|
||||
.mi { color: #099 } // Literal.Number.Integer
|
||||
.mo { color: #099 } // Literal.Number.Oct
|
||||
.sb { color: #d14 } // Literal.String.Backtick
|
||||
.sc { color: #d14 } // Literal.String.Char
|
||||
.sd { color: #d14 } // Literal.String.Doc
|
||||
.s2 { color: #d14 } // Literal.String.Double
|
||||
.se { color: #d14 } // Literal.String.Escape
|
||||
.sh { color: #d14 } // Literal.String.Heredoc
|
||||
.si { color: #d14 } // Literal.String.Interpol
|
||||
.sx { color: #d14 } // Literal.String.Other
|
||||
.sr { color: #009926 } // Literal.String.Regex
|
||||
.s1 { color: #d14 } // Literal.String.Single
|
||||
.ss { color: #990073 } // Literal.String.Symbol
|
||||
.bp { color: #999 } // Name.Builtin.Pseudo
|
||||
.vc { color: #008080 } // Name.Variable.Class
|
||||
.vg { color: #008080 } // Name.Variable.Global
|
||||
.vi { color: #008080 } // Name.Variable.Instance
|
||||
.il { color: #099 } // Literal.Number.Integer.Long
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
---
|
||||
title: Handles
|
||||
---
|
||||
|
||||
A handle is used to access the attributes of a Liquid object. By default, the handle is the object's title in lowercase with any spaces and special characters replaced by hyphens (-).
|
||||
|
||||
For example, a page with the title "About Us" can be accessed in Liquid via its handle `about-us` as shown below:
|
||||
|
||||
{% highlight liquid %}
|
||||
{% raw %}
|
||||
<!-- the content of the About Us page -->
|
||||
{{ pages.about-us.content }}
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
|
||||
## Creating handles
|
||||
|
||||
An object with the title "Shirt" will automatically be given the handle `shirt`. If there is already an object with the handle `shirt`, the handle will auto-increment. In other words, "Shirt" objects created after the first one will receive the handle `shirt-1`, `shirt-2`, and so on.
|
||||
|
||||
Whitespace in titles is replaced by hyphens in handles. For example, the title "My Shiny New Title" will be given the handle `my-shiny-new-title`.
|
||||
|
||||
Handles also determine the URL of their corresponding objects. For example, a page with the handle `about-us` would have the url `/pages/about-us`.
|
||||
|
||||
Websites often rely on static handles for pages, posts, or objects. To preserve design elements and avoid broken links, if you modify the title of an object, **its handle is not automatically updated**. For example, if you were to change a page title from "About Us" to "About This Website", its handle would still be `about-us`.
|
||||
|
||||
You can change an object's handle manually (TK how to change a handle manually)
|
||||
|
||||
## Accessing handle attributes
|
||||
|
||||
In many cases you may know the handle of a object whose attributes you want to access. You can access its attributes by pluralizing the name of the object, then using either the square bracket ( [ ] ) or dot ( . ) notation.
|
||||
|
||||
<div class="code-block code-block--input">
|
||||
{% highlight liquid %}
|
||||
{% raw %}
|
||||
{{ pages.about-us.title }}
|
||||
{{ pages["about-us"].title }}
|
||||
{% endraw %}
|
||||
{% endhighlight %}
|
||||
</div>
|
||||
|
||||
<div class="code-block code-block--output">
|
||||
{% highlight text %}
|
||||
About Us
|
||||
About Us
|
||||
{% endhighlight %}
|
||||
</div>
|
||||
|
||||
In the example above, notice that we are using `pages` as opposed to `page`.
|
||||
@@ -1,4 +0,0 @@
|
||||
---
|
||||
layout: default
|
||||
---
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
---
|
||||
title: Introduction
|
||||
---
|
||||
|
||||
Liquid code can be categorized into [**objects**](#objects), [**tags**](#tags), and [**filters**](#filters).
|
||||
|
||||
## Objects
|
||||
|
||||
**Objects** tell Liquid where to show content on a page. Objects and variable names are denoted by double curly braces: `{% raw %}{{{% endraw %}` and `{% raw %}}}{% endraw %}`.
|
||||
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ page.title }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
Introduction
|
||||
```
|
||||
|
||||
In this case, Liquid is rendering the content of an object called `page.title`, and that object contains the text `Introduction`.
|
||||
|
||||
## Tags
|
||||
|
||||
**Tags** create the logic and control flow for templates. They are denoted by curly braces and percent signs: `{% raw %}{%{% endraw %}` and `{% raw %}%}{% endraw %}`.
|
||||
|
||||
The markup used in tags does not produce any visible text. This means that you can assign variables and create conditions and loops without showing any of the Liquid logic on the page.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% if user %}
|
||||
Hello {{ user.name }}!
|
||||
{% endif %}
|
||||
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
Hello Adam!
|
||||
```
|
||||
|
||||
Tags can be categorized into three types:
|
||||
|
||||
- [Control flow](/tags/control-flow)
|
||||
- [Iteration](/tags/iteration)
|
||||
- [Variable assignments](/tags/variable)
|
||||
|
||||
You can read more about each type of tag in their respective sections.
|
||||
|
||||
|
||||
## Filters
|
||||
|
||||
**Filters** change the output of a Liquid object. They are using within an output and are separated by a `|`.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "/my/fancy/url" | append: ".html" }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "/my/fancy/url" | append: ".html" }}
|
||||
```
|
||||
@@ -1,88 +0,0 @@
|
||||
---
|
||||
title: Operators
|
||||
---
|
||||
|
||||
Liquid includes many logical and comparison operators.
|
||||
|
||||
## Basic operators
|
||||
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><code>==</code></td>
|
||||
<td>equals</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>!=</code></td>
|
||||
<td>does not equal</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>></code></td>
|
||||
<td>greater than</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code><</code></td>
|
||||
<td>less than</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>>=</code></td>
|
||||
<td>greater than or equal to</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code><=</code></td>
|
||||
<td>less than or equal to</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>or</code></td>
|
||||
<td>logical or</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>and</code></td>
|
||||
<td>logical and</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
For example:
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% if product.title == "Awesome Shoes" %}
|
||||
These shoes are awesome!
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
You can use multiple operators in a tag:
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% if product.type == "Shirt" or product.type == "Shoes" %}
|
||||
This is a shirt or a pair of shoes.
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
## contains
|
||||
|
||||
`contains` checks for the presence of a substring inside a string.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% if product.title contains 'Pack' %}
|
||||
This product's title contains the word Pack.
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
`contains` can also check for the presence of a string in an array of strings.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% if product.tags contains 'Hello' %}
|
||||
This product has been tagged with 'Hello'.
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
`contains` can only search strings. You cannot use it to check for an object in an array of objects.
|
||||
@@ -1,76 +0,0 @@
|
||||
---
|
||||
title: Truthy and falsy
|
||||
---
|
||||
|
||||
In programming, anything that returns `true` in a conditional is called **truthy**. Anything that returns `false` in a conditional is called **falsy**. All object types can be described as either truthy or falsy.
|
||||
|
||||
- [Truthy](#truthy)
|
||||
- [Falsy](#falsy)
|
||||
- [Summary](#summary)
|
||||
|
||||
## Truthy
|
||||
|
||||
All values in Liquid are truthy except `nil` and `false`.
|
||||
|
||||
In the example below, the string "Tobi" is not a boolean, but it is truthy in a conditional:
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% assign tobi = "Tobi" %}
|
||||
|
||||
{% if tobi == true %}
|
||||
This condition will always be true.
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
[Strings](/basics/types/#string), even when empty, are truthy. The example below will result in empty HTML tags if `settings.fp_heading` is empty:
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% if settings.fp_heading %}
|
||||
<h1>{{ settings.fp_heading }}</h1>
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```html
|
||||
<h1></h1>
|
||||
```
|
||||
|
||||
[EmptyDrops](/basics/types/#emptydrop) are also truthy. In the example below, if `settings.page` is an empty string or set to a hidden or deleted object, you will end up with an EmptyDrop. The result is an empty `div`:
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% if pages[settings.page] %}
|
||||
<div>{{ pages[settings.page].content }}</div>
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```html
|
||||
<div></div>
|
||||
```
|
||||
|
||||
## Falsy
|
||||
|
||||
The falsy values in Liquid are [`nil`](/basics/types/#nil) and [`false`](/basics/types/#boolean).
|
||||
|
||||
## Summary
|
||||
|
||||
The table below summarizes what is truthy or falsy in Liquid.
|
||||
|
||||
| | truthy | falsy |
|
||||
| ------------- |:-------------:|:-------------:|
|
||||
| true | • | |
|
||||
| false | | • |
|
||||
| nil | | • |
|
||||
| string | • | |
|
||||
| empty string | • | |
|
||||
| 0 | • | |
|
||||
| integer | • | |
|
||||
| float | • | |
|
||||
| array | • | |
|
||||
| empty array | • | |
|
||||
| page | • | |
|
||||
| EmptyDrop | • | |
|
||||
-160
@@ -1,160 +0,0 @@
|
||||
---
|
||||
title: Types
|
||||
---
|
||||
|
||||
Liquid objects can have one of six types:
|
||||
|
||||
- [String](#string)
|
||||
- [Number](#number)
|
||||
- [Boolean](#boolean)
|
||||
- [Nil](#nil)
|
||||
- [Array](#array)
|
||||
- [EmptyDrop](#emptydrop)
|
||||
|
||||
You can initialize Liquid variables with the [assign](/tags/#assign) or [capture](/tags/#capture) tags.
|
||||
|
||||
## String
|
||||
|
||||
Declare a string by wrapping a variable's value in single or double quotes:
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% assign my_string = "Hello World!" %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
## Number
|
||||
|
||||
Numbers include floats and integers:
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% assign my_int = 25 %}
|
||||
{% assign my_float = 39.756 %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
## Boolean
|
||||
|
||||
Booleans are either `true` or `false`. No quotations are necessary when declaring a boolean:
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% assign foo = true %}
|
||||
{% assign bar = false %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
## Nil
|
||||
|
||||
Nil is a special empty value that is returned when Liquid code has no results. It is **not** a string with the characters "nil".
|
||||
|
||||
Nil is [treated as false](/basics/truthy-and-falsy) in the conditions of `if` blocks and other Liquid tags that check the truthfulness of a statement.
|
||||
|
||||
In the following example, if the user does not exist (that is, `user` returns `nil`), Liquid will not print the greeting:
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% if user %}
|
||||
Hello {{ user.name }}!
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
Tags or outputs that return `nil` will not print anything to the page.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
The current user is {{ user.name }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
The current user is
|
||||
```
|
||||
|
||||
## Array
|
||||
|
||||
Arrays hold lists of variables of any type.
|
||||
|
||||
### Accessing items in arrays
|
||||
|
||||
To access all the items in an array, you can loop through each item in the array using an [iteration tag](/tags/iteration/).
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
<!-- if site.users = "Tobi", "Laura", "Tetsuro", "Adam" -->
|
||||
{% for user in site.users %}
|
||||
{{ user }}
|
||||
{% endfor %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{% raw %}
|
||||
Tobi Laura Tetsuro Adam
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
### Accessing specific items in arrays
|
||||
|
||||
You can use square bracket `[` `]` notation to access a specific item in an array. Array indexing starts at zero.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
<!-- if site.users = "Tobi", "Laura", "Tetsuro", "Adam" -->
|
||||
{{ site.users[0] }}
|
||||
{{ site.users[1] }}
|
||||
{{ site.users[3] }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
Tobi
|
||||
Laura
|
||||
Adam
|
||||
```
|
||||
|
||||
### Initializing arrays
|
||||
|
||||
You cannot initialize arrays using only Liquid.
|
||||
|
||||
You can, however, use the [split](/filters/split) filter to break a string into an array of substrings.
|
||||
|
||||
## EmptyDrop
|
||||
|
||||
An EmptyDrop object is returned if you try to access a deleted object by name. In the example below, `page_1`, `page_2` and `page_3` are all EmptyDrop objects.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% assign variable = "hello" %}
|
||||
{% assign page_1 = pages[variable] %}
|
||||
{% assign page_2 = pages["does-not-exist"] %}
|
||||
{% assign page_3 = pages.this-handle-does-not-exist %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
EmptyDrop objects only have one attribute, `empty?`, which is always *true*.
|
||||
|
||||
Collections and pages that *do* exist do not have an `empty?` attribute. Their `empty?` is "falsy", which means that calling it inside an if statement will return *false*. When using an `unless` statement on existing collections and pages, `empty?` will return `true`.
|
||||
|
||||
### Checking for emptiness
|
||||
|
||||
Using the `empty?` attribute, you can check to see if an object exists or not before you access any of its attributes.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% unless pages.about.empty? %}
|
||||
<!-- This will only print if the page with handle 'about' is not empty -->
|
||||
<h1>{{ pages.frontpage.title }}</h1>
|
||||
<div>{{ pages.frontpage.content }}</div>
|
||||
{% endunless %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
If you don't check for emptiness first, Liquid might print empty HTML elements to the page:
|
||||
|
||||
```html
|
||||
<h1></h1>
|
||||
<div></div>
|
||||
```
|
||||
@@ -0,0 +1,41 @@
|
||||
module ProductsFilter
|
||||
def price(integer)
|
||||
sprintf("$%.2d USD", integer / 100.0)
|
||||
end
|
||||
|
||||
def prettyprint(text)
|
||||
text.gsub( /\*(.*)\*/, '<b>\1</b>' )
|
||||
end
|
||||
|
||||
def count(array)
|
||||
array.size
|
||||
end
|
||||
|
||||
def paragraph(p)
|
||||
"<p>#{p}</p>"
|
||||
end
|
||||
end
|
||||
|
||||
class Servlet < LiquidServlet
|
||||
|
||||
def index
|
||||
{ 'date' => Time.now }
|
||||
end
|
||||
|
||||
def products
|
||||
{ 'products' => products_list, 'section' => 'Snowboards', 'cool_products' => true}
|
||||
end
|
||||
|
||||
def description
|
||||
"List of Products ~ This is a list of products with price and description."
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def products_list
|
||||
[{'name' => 'Arbor Draft', 'price' => 39900, 'description' => 'the *arbor draft* is a excellent product' },
|
||||
{'name' => 'Arbor Element', 'price' => 40000, 'description' => 'the *arbor element* rocks for freestyling'},
|
||||
{'name' => 'Arbor Diamond', 'price' => 59900, 'description' => 'the *arbor diamond* is a made up product because im obsessed with arbor and have no creativity'}]
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,28 @@
|
||||
class LiquidServlet < WEBrick::HTTPServlet::AbstractServlet
|
||||
|
||||
def do_GET(req, res)
|
||||
handle(:get, req, res)
|
||||
end
|
||||
|
||||
def do_POST(req, res)
|
||||
handle(:post, req, res)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def handle(type, req, res)
|
||||
@request, @response = req, res
|
||||
|
||||
@request.path_info =~ /(\w+)$/
|
||||
@action = $1 || 'index'
|
||||
@assigns = send(@action) if respond_to?(@action)
|
||||
|
||||
@response['Content-Type'] = "text/html"
|
||||
@response.status = 200
|
||||
@response.body = Liquid::Template.parse(read_template).render(@assigns, :filters => [ProductsFilter])
|
||||
end
|
||||
|
||||
def read_template(filename = @action)
|
||||
File.read( File.dirname(__FILE__) + "/templates/#{filename}.liquid" )
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
require 'webrick'
|
||||
require 'rexml/document'
|
||||
|
||||
DIR = File.expand_path(File.dirname(__FILE__))
|
||||
|
||||
require DIR + '/../../lib/liquid'
|
||||
require DIR + '/liquid_servlet'
|
||||
require DIR + '/example_servlet'
|
||||
|
||||
# Setup webrick
|
||||
server = WEBrick::HTTPServer.new( :Port => ARGV[1] || 3000 )
|
||||
server.mount('/', Servlet)
|
||||
trap("INT"){ server.shutdown }
|
||||
server.start
|
||||
@@ -0,0 +1,6 @@
|
||||
<p>Hello world!</p>
|
||||
|
||||
<p>It is {{date}}</p>
|
||||
|
||||
|
||||
<p>Check out the <a href="http://localhost:3000/products">Products</a> screen </p>
|
||||
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
||||
<meta http-equiv="Content-Language" content="en-us" />
|
||||
|
||||
<title>products</title>
|
||||
|
||||
<meta name="ROBOTS" content="ALL" />
|
||||
<meta http-equiv="imagetoolbar" content="no" />
|
||||
<meta name="MSSmartTagsPreventParsing" content="true" />
|
||||
<meta name="Copyright" content="(c) 2005 Copyright content: Copyright design: Tobias Luetke" />
|
||||
<!-- (c) Copyright 2005 by Tobias Luetke All Rights Reserved. -->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<h1>{{ description | split: '~' | first }}</h1>
|
||||
|
||||
<h2>{{ description | split: '~' | last }}</h2>
|
||||
|
||||
<h2>There are currently {{products | count}} products in the {{section}} catalog</h2>
|
||||
|
||||
{% if cool_products %}
|
||||
Cool products :)
|
||||
{% else %}
|
||||
Uncool products :(
|
||||
{% endif %}
|
||||
|
||||
<ul id="products">
|
||||
|
||||
{% for product in products %}
|
||||
<li>
|
||||
<h2>{{product.name}}</h2>
|
||||
Only {{product.price | price }}
|
||||
|
||||
{{product.description | prettyprint | paragraph }}
|
||||
|
||||
{{ 'it rocks!' | paragraph }}
|
||||
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
||||
</ul>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,6 @@
|
||||
require 'mkmf'
|
||||
|
||||
dir_config("liquid_ext")
|
||||
have_library("c", "main")
|
||||
|
||||
create_makefile("liquid_ext")
|
||||
@@ -0,0 +1,764 @@
|
||||
/* A recursive-descent parser generated by peg 0.1.9 */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#define YYRULECOUNT 14
|
||||
|
||||
//uncomment to get more debug instrumentation
|
||||
//
|
||||
//#define YY_DEBUG
|
||||
|
||||
#include <ruby.h>
|
||||
|
||||
#define EMIT(sym, data) \
|
||||
rb_ary_push(ctx->rb_tokens, rb_ary_new3(2, ID2SYM(rb_intern(sym)), data));
|
||||
|
||||
#define yy_rb_str rb_str_new(yytext, yyleng)
|
||||
|
||||
#define YYSTYPE VALUE
|
||||
#define YY_CTX_LOCAL
|
||||
#define YY_CTX_MEMBERS VALUE rb_tokens; char *p; int p_len;
|
||||
|
||||
#define YY_INPUT(buf, result, max_size) { \
|
||||
result = ctx->p_len; \
|
||||
if (result>0 || EOF == ctx->p[0]) { \
|
||||
if (max_size < result) { result = max_size; } \
|
||||
strncpy(buf, ctx->p, result); \
|
||||
buf[result] = '\0'; \
|
||||
yyprintf((stderr, "\nREFILLING %d chars now:<%s>", result, buf)); \
|
||||
ctx->p += result; ctx->p_len -= result; \
|
||||
yyprintf((stderr, "\nREFILLING DONE size left: %d <%s>", ctx->p_len, ctx->p)); \
|
||||
} \
|
||||
}
|
||||
|
||||
#ifndef YY_LOCAL
|
||||
#define YY_LOCAL(T) static T
|
||||
#endif
|
||||
#ifndef YY_ACTION
|
||||
#define YY_ACTION(T) static T
|
||||
#endif
|
||||
#ifndef YY_RULE
|
||||
#define YY_RULE(T) static T
|
||||
#endif
|
||||
#ifndef YY_PARSE
|
||||
#define YY_PARSE(T) T
|
||||
#endif
|
||||
#ifndef YYPARSE
|
||||
#define YYPARSE yyparse
|
||||
#endif
|
||||
#ifndef YYPARSEFROM
|
||||
#define YYPARSEFROM yyparsefrom
|
||||
#endif
|
||||
#ifndef YY_INPUT
|
||||
#define YY_INPUT(buf, result, max_size) \
|
||||
{ \
|
||||
int yyc= getchar(); \
|
||||
result= (EOF == yyc) ? 0 : (*(buf)= yyc, 1); \
|
||||
yyprintf((stderr, "<%c>", yyc)); \
|
||||
}
|
||||
#endif
|
||||
#ifndef YY_BEGIN
|
||||
#define YY_BEGIN ( ctx->begin= ctx->pos, 1)
|
||||
#endif
|
||||
#ifndef YY_END
|
||||
#define YY_END ( ctx->end= ctx->pos, 1)
|
||||
#endif
|
||||
#ifdef YY_DEBUG
|
||||
# define yyprintf(args) fprintf args
|
||||
#else
|
||||
# define yyprintf(args)
|
||||
#endif
|
||||
#ifndef YYSTYPE
|
||||
#define YYSTYPE int
|
||||
#endif
|
||||
|
||||
#ifndef YY_PART
|
||||
|
||||
typedef struct _yycontext yycontext;
|
||||
typedef void (*yyaction)(yycontext *ctx, char *yytext, int yyleng);
|
||||
typedef struct _yythunk { int begin, end; yyaction action; struct _yythunk *next; } yythunk;
|
||||
|
||||
struct _yycontext {
|
||||
char *buf;
|
||||
int buflen;
|
||||
int pos;
|
||||
int limit;
|
||||
char *text;
|
||||
int textlen;
|
||||
int begin;
|
||||
int end;
|
||||
int textmax;
|
||||
yythunk *thunks;
|
||||
int thunkslen;
|
||||
int thunkpos;
|
||||
YYSTYPE yy;
|
||||
YYSTYPE *val;
|
||||
YYSTYPE *vals;
|
||||
int valslen;
|
||||
#ifdef YY_CTX_MEMBERS
|
||||
YY_CTX_MEMBERS
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef YY_CTX_LOCAL
|
||||
#define YY_CTX_PARAM_ yycontext *yyctx,
|
||||
#define YY_CTX_PARAM yycontext *yyctx
|
||||
#define YY_CTX_ARG_ yyctx,
|
||||
#define YY_CTX_ARG yyctx
|
||||
#else
|
||||
#define YY_CTX_PARAM_
|
||||
#define YY_CTX_PARAM
|
||||
#define YY_CTX_ARG_
|
||||
#define YY_CTX_ARG
|
||||
yycontext yyctx0;
|
||||
yycontext *yyctx= &yyctx0;
|
||||
#endif
|
||||
|
||||
YY_LOCAL(int) yyrefill(yycontext *ctx)
|
||||
{
|
||||
int yyn;
|
||||
while (ctx->buflen - ctx->pos < 512)
|
||||
{
|
||||
ctx->buflen *= 2;
|
||||
ctx->buf= (char *)realloc(ctx->buf, ctx->buflen);
|
||||
}
|
||||
YY_INPUT((ctx->buf + ctx->pos), yyn, (ctx->buflen - ctx->pos));
|
||||
if (!yyn) return 0;
|
||||
ctx->limit += yyn;
|
||||
return 1;
|
||||
}
|
||||
|
||||
YY_LOCAL(int) yymatchDot(yycontext *ctx)
|
||||
{
|
||||
if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0;
|
||||
++ctx->pos;
|
||||
return 1;
|
||||
}
|
||||
|
||||
YY_LOCAL(int) yymatchChar(yycontext *ctx, int c)
|
||||
{
|
||||
if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0;
|
||||
if ((unsigned char)ctx->buf[ctx->pos] == c)
|
||||
{
|
||||
++ctx->pos;
|
||||
yyprintf((stderr, " ok yymatchChar(ctx, %c) @ %s\n", c, ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
}
|
||||
yyprintf((stderr, " fail yymatchChar(ctx, %c) @ %s\n", c, ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
|
||||
YY_LOCAL(int) yymatchString(yycontext *ctx, char *s)
|
||||
{
|
||||
int yysav= ctx->pos;
|
||||
while (*s)
|
||||
{
|
||||
if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0;
|
||||
if (ctx->buf[ctx->pos] != *s)
|
||||
{
|
||||
ctx->pos= yysav;
|
||||
return 0;
|
||||
}
|
||||
++s;
|
||||
++ctx->pos;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
YY_LOCAL(int) yymatchClass(yycontext *ctx, unsigned char *bits)
|
||||
{
|
||||
int c;
|
||||
if (ctx->pos >= ctx->limit && !yyrefill(ctx)) return 0;
|
||||
c= (unsigned char)ctx->buf[ctx->pos];
|
||||
if (bits[c >> 3] & (1 << (c & 7)))
|
||||
{
|
||||
++ctx->pos;
|
||||
yyprintf((stderr, " ok yymatchClass @ %s\n", ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
}
|
||||
yyprintf((stderr, " fail yymatchClass @ %s\n", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
|
||||
YY_LOCAL(void) yyDo(yycontext *ctx, yyaction action, int begin, int end)
|
||||
{
|
||||
while (ctx->thunkpos >= ctx->thunkslen)
|
||||
{
|
||||
ctx->thunkslen *= 2;
|
||||
ctx->thunks= (yythunk *)realloc(ctx->thunks, sizeof(yythunk) * ctx->thunkslen);
|
||||
}
|
||||
ctx->thunks[ctx->thunkpos].begin= begin;
|
||||
ctx->thunks[ctx->thunkpos].end= end;
|
||||
ctx->thunks[ctx->thunkpos].action= action;
|
||||
++ctx->thunkpos;
|
||||
}
|
||||
|
||||
YY_LOCAL(int) yyText(yycontext *ctx, int begin, int end)
|
||||
{
|
||||
int yyleng= end - begin;
|
||||
if (yyleng <= 0)
|
||||
yyleng= 0;
|
||||
else
|
||||
{
|
||||
while (ctx->textlen < (yyleng + 1))
|
||||
{
|
||||
ctx->textlen *= 2;
|
||||
ctx->text= (char *)realloc(ctx->text, ctx->textlen);
|
||||
}
|
||||
memcpy(ctx->text, ctx->buf + begin, yyleng);
|
||||
}
|
||||
ctx->text[yyleng]= '\0';
|
||||
return yyleng;
|
||||
}
|
||||
|
||||
YY_LOCAL(void) yyDone(yycontext *ctx)
|
||||
{
|
||||
int pos;
|
||||
for (pos= 0; pos < ctx->thunkpos; ++pos)
|
||||
{
|
||||
yythunk *thunk= &ctx->thunks[pos];
|
||||
int yyleng= thunk->end ? yyText(ctx, thunk->begin, thunk->end) : thunk->begin;
|
||||
yyprintf((stderr, "DO [%d] %p %s\n", pos, thunk->action, ctx->text));
|
||||
thunk->action(ctx, ctx->text, yyleng);
|
||||
}
|
||||
ctx->thunkpos= 0;
|
||||
}
|
||||
|
||||
YY_LOCAL(void) yyCommit(yycontext *ctx)
|
||||
{
|
||||
if ((ctx->limit -= ctx->pos))
|
||||
{
|
||||
memmove(ctx->buf, ctx->buf + ctx->pos, ctx->limit);
|
||||
}
|
||||
ctx->begin -= ctx->pos;
|
||||
ctx->end -= ctx->pos;
|
||||
ctx->pos= ctx->thunkpos= 0;
|
||||
}
|
||||
|
||||
YY_LOCAL(int) yyAccept(yycontext *ctx, int tp0)
|
||||
{
|
||||
if (tp0)
|
||||
{
|
||||
fprintf(stderr, "accept denied at %d\n", tp0);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
yyDone(ctx);
|
||||
yyCommit(ctx);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
YY_LOCAL(void) yyPush(yycontext *ctx, char *text, int count) { ctx->val += count; }
|
||||
YY_LOCAL(void) yyPop(yycontext *ctx, char *text, int count) { ctx->val -= count; }
|
||||
YY_LOCAL(void) yySet(yycontext *ctx, char *text, int count) { ctx->val[count]= ctx->yy; }
|
||||
|
||||
#endif /* YY_PART */
|
||||
|
||||
#define YYACCEPT yyAccept(ctx, yythunkpos0)
|
||||
|
||||
YY_RULE(int) yy_digit(yycontext *ctx); /* 14 */
|
||||
YY_RULE(int) yy_float(yycontext *ctx); /* 13 */
|
||||
YY_RULE(int) yy_integer(yycontext *ctx); /* 12 */
|
||||
YY_RULE(int) yy_rangelet(yycontext *ctx); /* 11 */
|
||||
YY_RULE(int) yy_identifier(yycontext *ctx); /* 10 */
|
||||
YY_RULE(int) yy_accessors(yycontext *ctx); /* 9 */
|
||||
YY_RULE(int) yy_numeric(yycontext *ctx); /* 8 */
|
||||
YY_RULE(int) yy_string(yycontext *ctx); /* 7 */
|
||||
YY_RULE(int) yy_const(yycontext *ctx); /* 6 */
|
||||
YY_RULE(int) yy_hash(yycontext *ctx); /* 5 */
|
||||
YY_RULE(int) yy_range(yycontext *ctx); /* 4 */
|
||||
YY_RULE(int) yy_entity(yycontext *ctx); /* 3 */
|
||||
YY_RULE(int) yy_primary(yycontext *ctx); /* 2 */
|
||||
YY_RULE(int) yy_grammar(yycontext *ctx); /* 1 */
|
||||
|
||||
YY_ACTION(void) yy_4_const(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_4_const\n"));
|
||||
yy = Qnil; ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_3_const(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_3_const\n"));
|
||||
yy = Qnil; ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_2_const(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_2_const\n"));
|
||||
yy = Qfalse; ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_1_const(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_1_const\n"));
|
||||
yy = Qtrue; ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_1_integer(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_1_integer\n"));
|
||||
yy = rb_funcall(rb_cObject, rb_intern("Integer"), 1, yy_rb_str); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_1_float(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_1_float\n"));
|
||||
yy = rb_funcall(rb_cObject, rb_intern("Float"), 1, yy_rb_str); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_2_string(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_2_string\n"));
|
||||
yy = yy_rb_str; ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_1_string(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_1_string\n"));
|
||||
yy = yy_rb_str; ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_1_range(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_1_range\n"));
|
||||
EMIT("range", Qnil); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_1_rangelet(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define var ctx->val[-1]
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_1_rangelet\n"));
|
||||
EMIT("id", var); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
#undef var
|
||||
}
|
||||
YY_ACTION(void) yy_1_entity(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_1_entity\n"));
|
||||
EMIT("id", yy_rb_str); EMIT("lookup", Qnil); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_5_accessors(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_5_accessors\n"));
|
||||
EMIT("id", yy_rb_str); EMIT("call", Qnil); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_4_accessors(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_4_accessors\n"));
|
||||
EMIT("buildin", rb_str_new2("size")); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_3_accessors(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_3_accessors\n"));
|
||||
EMIT("buildin", rb_str_new2("last")); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_2_accessors(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_2_accessors\n"));
|
||||
EMIT("buildin", rb_str_new2("first")); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_1_accessors(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_1_accessors\n"));
|
||||
EMIT("call", Qnil); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
YY_ACTION(void) yy_3_primary(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define var ctx->val[-1]
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_3_primary\n"));
|
||||
EMIT("id", var); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
#undef var
|
||||
}
|
||||
YY_ACTION(void) yy_2_primary(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define var ctx->val[-1]
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_2_primary\n"));
|
||||
EMIT("id", var); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
#undef var
|
||||
}
|
||||
YY_ACTION(void) yy_1_primary(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define var ctx->val[-1]
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_1_primary\n"));
|
||||
EMIT("id", var); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
#undef var
|
||||
}
|
||||
YY_ACTION(void) yy_1_grammar(yycontext *ctx, char *yytext, int yyleng)
|
||||
{
|
||||
#define yy ctx->yy
|
||||
#define yypos ctx->pos
|
||||
#define yythunkpos ctx->thunkpos
|
||||
yyprintf((stderr, "do yy_1_grammar\n"));
|
||||
EMIT("lookup", Qnil); ;
|
||||
#undef yythunkpos
|
||||
#undef yypos
|
||||
#undef yy
|
||||
}
|
||||
|
||||
YY_RULE(int) yy_digit(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
|
||||
yyprintf((stderr, "%s\n", "digit")); if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\000\000\377\003\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l1;
|
||||
yyprintf((stderr, " ok %s @ %s\n", "digit", ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
l1:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "digit", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
YY_RULE(int) yy_float(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
|
||||
yyprintf((stderr, "%s\n", "float")); yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l2;
|
||||
{ int yypos3= ctx->pos, yythunkpos3= ctx->thunkpos; if (!yymatchChar(ctx, '-')) goto l3; goto l4;
|
||||
l3:; ctx->pos= yypos3; ctx->thunkpos= yythunkpos3;
|
||||
}
|
||||
l4:; if (!yy_digit(ctx)) goto l2; if (!yymatchChar(ctx, '.')) goto l2; if (!yy_digit(ctx)) goto l2;
|
||||
l5:;
|
||||
{ int yypos6= ctx->pos, yythunkpos6= ctx->thunkpos; if (!yy_digit(ctx)) goto l6; goto l5;
|
||||
l6:; ctx->pos= yypos6; ctx->thunkpos= yythunkpos6;
|
||||
} yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l2; yyDo(ctx, yy_1_float, ctx->begin, ctx->end);
|
||||
yyprintf((stderr, " ok %s @ %s\n", "float", ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
l2:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "float", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
YY_RULE(int) yy_integer(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
|
||||
yyprintf((stderr, "%s\n", "integer")); yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l7;
|
||||
{ int yypos8= ctx->pos, yythunkpos8= ctx->thunkpos; if (!yymatchChar(ctx, '-')) goto l8; goto l9;
|
||||
l8:; ctx->pos= yypos8; ctx->thunkpos= yythunkpos8;
|
||||
}
|
||||
l9:; if (!yy_digit(ctx)) goto l7;
|
||||
l10:;
|
||||
{ int yypos11= ctx->pos, yythunkpos11= ctx->thunkpos; if (!yy_digit(ctx)) goto l11; goto l10;
|
||||
l11:; ctx->pos= yypos11; ctx->thunkpos= yythunkpos11;
|
||||
} yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l7; yyDo(ctx, yy_1_integer, ctx->begin, ctx->end);
|
||||
yyprintf((stderr, " ok %s @ %s\n", "integer", ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
l7:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "integer", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
YY_RULE(int) yy_rangelet(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; yyDo(ctx, yyPush, 1, 0);
|
||||
yyprintf((stderr, "%s\n", "rangelet"));
|
||||
{ int yypos13= ctx->pos, yythunkpos13= ctx->thunkpos; if (!yy_integer(ctx)) goto l14; yyDo(ctx, yySet, -1, 0); yyDo(ctx, yy_1_rangelet, ctx->begin, ctx->end); goto l13;
|
||||
l14:; ctx->pos= yypos13; ctx->thunkpos= yythunkpos13; if (!yy_entity(ctx)) goto l12;
|
||||
}
|
||||
l13:;
|
||||
yyprintf((stderr, " ok %s @ %s\n", "rangelet", ctx->buf+ctx->pos)); yyDo(ctx, yyPop, 1, 0);
|
||||
return 1;
|
||||
l12:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "rangelet", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
YY_RULE(int) yy_identifier(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
|
||||
yyprintf((stderr, "%s\n", "identifier")); if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\000\000\000\000\376\377\377\007\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l15;
|
||||
l16:;
|
||||
{ int yypos17= ctx->pos, yythunkpos17= ctx->thunkpos; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\000\040\377\003\376\377\377\207\376\377\377\007\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l17; goto l16;
|
||||
l17:; ctx->pos= yypos17; ctx->thunkpos= yythunkpos17;
|
||||
}
|
||||
{ int yypos18= ctx->pos, yythunkpos18= ctx->thunkpos; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\002\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l18; goto l19;
|
||||
l18:; ctx->pos= yypos18; ctx->thunkpos= yythunkpos18;
|
||||
}
|
||||
l19:;
|
||||
yyprintf((stderr, " ok %s @ %s\n", "identifier", ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
l15:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "identifier", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
YY_RULE(int) yy_accessors(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
|
||||
yyprintf((stderr, "%s\n", "accessors"));
|
||||
{ int yypos21= ctx->pos, yythunkpos21= ctx->thunkpos; if (!yy_hash(ctx)) goto l22; yyDo(ctx, yy_1_accessors, ctx->begin, ctx->end); goto l21;
|
||||
l22:; ctx->pos= yypos21; ctx->thunkpos= yythunkpos21; if (!yymatchString(ctx, ".first")) goto l23; yyDo(ctx, yy_2_accessors, ctx->begin, ctx->end); goto l21;
|
||||
l23:; ctx->pos= yypos21; ctx->thunkpos= yythunkpos21; if (!yymatchString(ctx, ".last")) goto l24; yyDo(ctx, yy_3_accessors, ctx->begin, ctx->end); goto l21;
|
||||
l24:; ctx->pos= yypos21; ctx->thunkpos= yythunkpos21; if (!yymatchString(ctx, ".size")) goto l25; yyDo(ctx, yy_4_accessors, ctx->begin, ctx->end); goto l21;
|
||||
l25:; ctx->pos= yypos21; ctx->thunkpos= yythunkpos21; if (!yymatchChar(ctx, '.')) goto l20; yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l20; if (!yy_identifier(ctx)) goto l20; yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l20; yyDo(ctx, yy_5_accessors, ctx->begin, ctx->end);
|
||||
}
|
||||
l21:;
|
||||
yyprintf((stderr, " ok %s @ %s\n", "accessors", ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
l20:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "accessors", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
YY_RULE(int) yy_numeric(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
|
||||
yyprintf((stderr, "%s\n", "numeric"));
|
||||
{ int yypos27= ctx->pos, yythunkpos27= ctx->thunkpos; if (!yy_float(ctx)) goto l28; goto l27;
|
||||
l28:; ctx->pos= yypos27; ctx->thunkpos= yythunkpos27; if (!yy_integer(ctx)) goto l26;
|
||||
}
|
||||
l27:;
|
||||
yyprintf((stderr, " ok %s @ %s\n", "numeric", ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
l26:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "numeric", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
YY_RULE(int) yy_string(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
|
||||
yyprintf((stderr, "%s\n", "string"));
|
||||
{ int yypos30= ctx->pos, yythunkpos30= ctx->thunkpos; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l31; yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l31;
|
||||
l32:;
|
||||
{ int yypos33= ctx->pos, yythunkpos33= ctx->thunkpos;
|
||||
{ int yypos34= ctx->pos, yythunkpos34= ctx->thunkpos; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l34; goto l33;
|
||||
l34:; ctx->pos= yypos34; ctx->thunkpos= yythunkpos34;
|
||||
} if (!yymatchDot(ctx)) goto l33; goto l32;
|
||||
l33:; ctx->pos= yypos33; ctx->thunkpos= yythunkpos33;
|
||||
} yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l31; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\200\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l31; yyDo(ctx, yy_1_string, ctx->begin, ctx->end); goto l30;
|
||||
l31:; ctx->pos= yypos30; ctx->thunkpos= yythunkpos30; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l29; yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l29;
|
||||
l35:;
|
||||
{ int yypos36= ctx->pos, yythunkpos36= ctx->thunkpos;
|
||||
{ int yypos37= ctx->pos, yythunkpos37= ctx->thunkpos; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l37; goto l36;
|
||||
l37:; ctx->pos= yypos37; ctx->thunkpos= yythunkpos37;
|
||||
} if (!yymatchDot(ctx)) goto l36; goto l35;
|
||||
l36:; ctx->pos= yypos36; ctx->thunkpos= yythunkpos36;
|
||||
} yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l29; if (!yymatchClass(ctx, (unsigned char *)"\000\000\000\000\004\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000")) goto l29; yyDo(ctx, yy_2_string, ctx->begin, ctx->end);
|
||||
}
|
||||
l30:;
|
||||
yyprintf((stderr, " ok %s @ %s\n", "string", ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
l29:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "string", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
YY_RULE(int) yy_const(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
|
||||
yyprintf((stderr, "%s\n", "const"));
|
||||
{ int yypos39= ctx->pos, yythunkpos39= ctx->thunkpos; if (!yymatchString(ctx, "true")) goto l40; yyDo(ctx, yy_1_const, ctx->begin, ctx->end); goto l39;
|
||||
l40:; ctx->pos= yypos39; ctx->thunkpos= yythunkpos39; if (!yymatchString(ctx, "false")) goto l41; yyDo(ctx, yy_2_const, ctx->begin, ctx->end); goto l39;
|
||||
l41:; ctx->pos= yypos39; ctx->thunkpos= yythunkpos39; if (!yymatchString(ctx, "nil")) goto l42; yyDo(ctx, yy_3_const, ctx->begin, ctx->end); goto l39;
|
||||
l42:; ctx->pos= yypos39; ctx->thunkpos= yythunkpos39; if (!yymatchString(ctx, "null")) goto l38; yyDo(ctx, yy_4_const, ctx->begin, ctx->end);
|
||||
}
|
||||
l39:;
|
||||
yyprintf((stderr, " ok %s @ %s\n", "const", ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
l38:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "const", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
YY_RULE(int) yy_hash(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
|
||||
yyprintf((stderr, "%s\n", "hash")); if (!yymatchChar(ctx, '[')) goto l43;
|
||||
{ int yypos44= ctx->pos, yythunkpos44= ctx->thunkpos; if (!yy_primary(ctx)) goto l45; goto l44;
|
||||
l45:; ctx->pos= yypos44; ctx->thunkpos= yythunkpos44; if (!yy_entity(ctx)) goto l43;
|
||||
}
|
||||
l44:; if (!yymatchChar(ctx, ']')) goto l43;
|
||||
yyprintf((stderr, " ok %s @ %s\n", "hash", ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
l43:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "hash", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
YY_RULE(int) yy_range(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
|
||||
yyprintf((stderr, "%s\n", "range")); if (!yymatchChar(ctx, '(')) goto l46; if (!yy_rangelet(ctx)) goto l46; if (!yymatchString(ctx, "..")) goto l46; if (!yy_rangelet(ctx)) goto l46; if (!yymatchChar(ctx, ')')) goto l46; yyDo(ctx, yy_1_range, ctx->begin, ctx->end);
|
||||
yyprintf((stderr, " ok %s @ %s\n", "range", ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
l46:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "range", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
YY_RULE(int) yy_entity(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
|
||||
yyprintf((stderr, "%s\n", "entity")); yyText(ctx, ctx->begin, ctx->end); if (!(YY_BEGIN)) goto l47; if (!yy_identifier(ctx)) goto l47; yyText(ctx, ctx->begin, ctx->end); if (!(YY_END)) goto l47; yyDo(ctx, yy_1_entity, ctx->begin, ctx->end);
|
||||
l48:;
|
||||
{ int yypos49= ctx->pos, yythunkpos49= ctx->thunkpos; if (!yy_accessors(ctx)) goto l49; goto l48;
|
||||
l49:; ctx->pos= yypos49; ctx->thunkpos= yythunkpos49;
|
||||
}
|
||||
yyprintf((stderr, " ok %s @ %s\n", "entity", ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
l47:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "entity", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
YY_RULE(int) yy_primary(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos; yyDo(ctx, yyPush, 1, 0);
|
||||
yyprintf((stderr, "%s\n", "primary"));
|
||||
{ int yypos51= ctx->pos, yythunkpos51= ctx->thunkpos; if (!yy_const(ctx)) goto l52; yyDo(ctx, yySet, -1, 0); yyDo(ctx, yy_1_primary, ctx->begin, ctx->end); goto l51;
|
||||
l52:; ctx->pos= yypos51; ctx->thunkpos= yythunkpos51; if (!yy_string(ctx)) goto l53; yyDo(ctx, yySet, -1, 0); yyDo(ctx, yy_2_primary, ctx->begin, ctx->end); goto l51;
|
||||
l53:; ctx->pos= yypos51; ctx->thunkpos= yythunkpos51; if (!yy_numeric(ctx)) goto l50; yyDo(ctx, yySet, -1, 0); yyDo(ctx, yy_3_primary, ctx->begin, ctx->end);
|
||||
}
|
||||
l51:;
|
||||
yyprintf((stderr, " ok %s @ %s\n", "primary", ctx->buf+ctx->pos)); yyDo(ctx, yyPop, 1, 0);
|
||||
return 1;
|
||||
l50:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "primary", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
YY_RULE(int) yy_grammar(yycontext *ctx)
|
||||
{ int yypos0= ctx->pos, yythunkpos0= ctx->thunkpos;
|
||||
yyprintf((stderr, "%s\n", "grammar"));
|
||||
{ int yypos55= ctx->pos, yythunkpos55= ctx->thunkpos; if (!yy_primary(ctx)) goto l56; goto l55;
|
||||
l56:; ctx->pos= yypos55; ctx->thunkpos= yythunkpos55; if (!yy_entity(ctx)) goto l57; goto l55;
|
||||
l57:; ctx->pos= yypos55; ctx->thunkpos= yythunkpos55; if (!yy_range(ctx)) goto l58; goto l55;
|
||||
l58:; ctx->pos= yypos55; ctx->thunkpos= yythunkpos55; if (!yy_hash(ctx)) goto l54; yyDo(ctx, yy_1_grammar, ctx->begin, ctx->end);
|
||||
}
|
||||
l55:;
|
||||
yyprintf((stderr, " ok %s @ %s\n", "grammar", ctx->buf+ctx->pos));
|
||||
return 1;
|
||||
l54:; ctx->pos= yypos0; ctx->thunkpos= yythunkpos0;
|
||||
yyprintf((stderr, " fail %s @ %s\n", "grammar", ctx->buf+ctx->pos));
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifndef YY_PART
|
||||
|
||||
typedef int (*yyrule)(yycontext *ctx);
|
||||
|
||||
YY_PARSE(int) YYPARSEFROM(YY_CTX_PARAM_ yyrule yystart)
|
||||
{
|
||||
int yyok;
|
||||
if (!yyctx->buflen)
|
||||
{
|
||||
yyctx->buflen= 1024;
|
||||
yyctx->buf= (char *)malloc(yyctx->buflen);
|
||||
yyctx->textlen= 1024;
|
||||
yyctx->text= (char *)malloc(yyctx->textlen);
|
||||
yyctx->thunkslen= 32;
|
||||
yyctx->thunks= (yythunk *)malloc(sizeof(yythunk) * yyctx->thunkslen);
|
||||
yyctx->valslen= 32;
|
||||
yyctx->vals= (YYSTYPE *)malloc(sizeof(YYSTYPE) * yyctx->valslen);
|
||||
yyctx->begin= yyctx->end= yyctx->pos= yyctx->limit= yyctx->thunkpos= 0;
|
||||
}
|
||||
yyctx->begin= yyctx->end= yyctx->pos;
|
||||
yyctx->thunkpos= 0;
|
||||
yyctx->val= yyctx->vals;
|
||||
yyok= yystart(yyctx);
|
||||
if (yyok) yyDone(yyctx);
|
||||
yyCommit(yyctx);
|
||||
return yyok;
|
||||
}
|
||||
|
||||
YY_PARSE(int) YYPARSE(YY_CTX_PARAM)
|
||||
{
|
||||
return YYPARSEFROM(YY_CTX_ARG_ yy_grammar);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
VALUE liquid_context_parse_impl(VALUE self, VALUE text) {
|
||||
char *p;
|
||||
int len;
|
||||
yycontext ctx;
|
||||
|
||||
memset(&ctx, 0, sizeof(yycontext));
|
||||
ctx.p = RSTRING_PTR(text);
|
||||
ctx.p_len = (int) RSTRING_LEN(text);
|
||||
ctx.rb_tokens = rb_ary_new();
|
||||
|
||||
yyparse(&ctx);
|
||||
|
||||
return ctx.rb_tokens;
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
|
||||
%{
|
||||
//uncomment to get more debug instrumentation
|
||||
//
|
||||
//#define YY_DEBUG
|
||||
|
||||
#include <ruby.h>
|
||||
|
||||
#define EMIT(sym, data) \
|
||||
rb_ary_push(ctx->rb_tokens, rb_ary_new3(2, ID2SYM(rb_intern(sym)), data));
|
||||
|
||||
#define yy_rb_str rb_str_new(yytext, yyleng)
|
||||
|
||||
#define YYSTYPE VALUE
|
||||
#define YY_CTX_LOCAL
|
||||
#define YY_CTX_MEMBERS VALUE rb_tokens; char *p; int p_len;
|
||||
|
||||
#define YY_INPUT(buf, result, max_size) { \
|
||||
result = ctx->p_len; \
|
||||
if (result>0 || EOF == ctx->p[0]) { \
|
||||
if (max_size < result) { result = max_size; } \
|
||||
strncpy(buf, ctx->p, result); \
|
||||
buf[result] = '\0'; \
|
||||
yyprintf((stderr, "\nREFILLING %d chars now:<%s>", result, buf)); \
|
||||
ctx->p += result; ctx->p_len -= result; \
|
||||
yyprintf((stderr, "\nREFILLING DONE size left: %d <%s>", ctx->p_len, ctx->p)); \
|
||||
} \
|
||||
}
|
||||
%}
|
||||
|
||||
grammar = primary
|
||||
| entity
|
||||
| range
|
||||
| hash { EMIT("lookup", Qnil); }
|
||||
;
|
||||
|
||||
hash = '[' (primary|entity) ']';
|
||||
|
||||
primary = var:const { EMIT("id", var); }
|
||||
| var:string { EMIT("id", var); }
|
||||
| var:numeric { EMIT("id", var); }
|
||||
;
|
||||
|
||||
accessors = hash { EMIT("call", Qnil); }
|
||||
| '.first' { EMIT("buildin", rb_str_new2("first")); }
|
||||
| '.last' { EMIT("buildin", rb_str_new2("last")); }
|
||||
| '.size' { EMIT("buildin", rb_str_new2("size")); }
|
||||
| '.' <identifier> { EMIT("id", yy_rb_str); EMIT("call", Qnil); }
|
||||
;
|
||||
|
||||
entity = <identifier> { EMIT("id", yy_rb_str); EMIT("lookup", Qnil); }
|
||||
accessors*
|
||||
;
|
||||
|
||||
rangelet = var:integer { EMIT("id", var); }
|
||||
| entity
|
||||
;
|
||||
|
||||
range = '(' rangelet '..' rangelet ')' { EMIT("range", Qnil); }
|
||||
|
||||
|
||||
string = ['] < ( !['] . )* > ['] { $$ = yy_rb_str; }
|
||||
| ["] < ( !["] . )* > ["] { $$ = yy_rb_str; }
|
||||
;
|
||||
|
||||
numeric = float
|
||||
| integer
|
||||
;
|
||||
|
||||
float = <'-'? digit+'.'digit+> { $$ = rb_funcall(rb_cObject, rb_intern("Float"), 1, yy_rb_str); }
|
||||
integer = <'-'? digit+> { $$ = rb_funcall(rb_cObject, rb_intern("Integer"), 1, yy_rb_str); }
|
||||
|
||||
|
||||
const = "true" { $$ = Qtrue; }
|
||||
| 'false' { $$ = Qfalse; }
|
||||
| 'nil' { $$ = Qnil; }
|
||||
| 'null' { $$ = Qnil; }
|
||||
;
|
||||
|
||||
digit = [0-9];
|
||||
identifier = [a-zA-Z][a-zA-Z0-9_\-]*[?!]?;
|
||||
|
||||
%%
|
||||
|
||||
VALUE liquid_context_parse_impl(VALUE self, VALUE text) {
|
||||
char *p;
|
||||
int len;
|
||||
yycontext ctx;
|
||||
|
||||
memset(&ctx, 0, sizeof(yycontext));
|
||||
ctx.p = RSTRING_PTR(text);
|
||||
ctx.p_len = (int) RSTRING_LEN(text);
|
||||
ctx.rb_tokens = rb_ary_new();
|
||||
|
||||
yyparse(&ctx);
|
||||
|
||||
return ctx.rb_tokens;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#include <ruby.h>
|
||||
|
||||
static VALUE rb_Liquid;
|
||||
static VALUE rb_Parser;
|
||||
|
||||
VALUE liquid_context_parse_impl(VALUE text);
|
||||
|
||||
void Init_liquid_ext()
|
||||
{
|
||||
rb_Liquid = rb_define_module("Liquid");
|
||||
rb_Parser = rb_define_class_under(rb_Liquid, "Parser", rb_cObject);
|
||||
rb_define_singleton_method(rb_Parser, "parse", liquid_context_parse_impl, 1);
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
---
|
||||
layout: null
|
||||
---
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<channel>
|
||||
<title>{{ site.title | xml_escape }}</title>
|
||||
<description>{{ site.description | xml_escape }}</description>
|
||||
<link>{{ site.url }}{{ site.baseurl }}/</link>
|
||||
<atom:link href="{{ "/feed.xml" | prepend: site.baseurl | prepend: site.url }}" rel="self" type="application/rss+xml"/>
|
||||
<pubDate>{{ site.time | date_to_rfc822 }}</pubDate>
|
||||
<lastBuildDate>{{ site.time | date_to_rfc822 }}</lastBuildDate>
|
||||
<generator>Jekyll v{{ jekyll.version }}</generator>
|
||||
{% for post in site.posts limit:10 %}
|
||||
<item>
|
||||
<title>{{ post.title | xml_escape }}</title>
|
||||
<description>{{ post.content | xml_escape }}</description>
|
||||
<pubDate>{{ post.date | date_to_rfc822 }}</pubDate>
|
||||
<link>{{ post.url | prepend: site.baseurl | prepend: site.url }}</link>
|
||||
<guid isPermaLink="true">{{ post.url | prepend: site.baseurl | prepend: site.url }}</guid>
|
||||
{% for tag in post.tags %}
|
||||
<category>{{ tag | xml_escape }}</category>
|
||||
{% endfor %}
|
||||
{% for cat in post.categories %}
|
||||
<category>{{ cat | xml_escape }}</category>
|
||||
{% endfor %}
|
||||
</item>
|
||||
{% endfor %}
|
||||
</channel>
|
||||
</rss>
|
||||
@@ -1,29 +0,0 @@
|
||||
---
|
||||
title: append
|
||||
---
|
||||
|
||||
Concatenates two strings and returns the concatenated value.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "/my/fancy/url" | append: ".html" }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "/my/fancy/url" | append: ".html" }}
|
||||
```
|
||||
|
||||
`append` can also be used with variables:
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% assign filename = "/index.html" %}
|
||||
{{ "website.com" | append: filename }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{% assign filename = "/index.html" %}
|
||||
{{ "website.com" | append: filename }}
|
||||
```
|
||||
@@ -1,27 +0,0 @@
|
||||
---
|
||||
title: capitalize
|
||||
---
|
||||
|
||||
Makes the first character of a string capitalized.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "title" | capitalize }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
Title
|
||||
```
|
||||
|
||||
`capitalize` only capitalizes the first character of the string, so later words are not affected:
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "my great title" | capitalize }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
My great title
|
||||
```
|
||||
@@ -1,47 +0,0 @@
|
||||
---
|
||||
title: ceil
|
||||
---
|
||||
|
||||
Rounds the input up to the nearest whole number. Liquid tries to convert the input to a number before the filter is applied.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ 1.2 | ceil }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ 1.2 | ceil }}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ 2.0 | ceil }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ 2.0 | ceil }}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ 183.357 | ceil }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ 183.357 | ceil }}
|
||||
```
|
||||
|
||||
Here the input value is a string:
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "3.5" | ceil }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "3.5" | ceil }}
|
||||
```
|
||||
@@ -1,37 +0,0 @@
|
||||
---
|
||||
title: date
|
||||
---
|
||||
|
||||
Converts a timestamp into another date format. The format for this syntax is the same as [`strftime`](//strftime.net).
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ article.published_at | date: "%a, %b %d, %y" }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
Fri, Jul 17, 15
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ article.published_at | date: "%Y" }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
2015
|
||||
```
|
||||
|
||||
`date` works on strings if they contain well-formatted dates:
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "March 14, 2016" | date: "%b %d, %y" }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "March 14, 2016" | date: "%b %d, %y" }}
|
||||
```
|
||||
@@ -1,44 +0,0 @@
|
||||
---
|
||||
title: default
|
||||
---
|
||||
|
||||
Allows you to specify a fallback in case a value doesn't exist. `default` will show its value if the left side is `nil`, `false`, or empty.
|
||||
|
||||
In this example, `product_price` is not defined, so the default value is used.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ product_price | default: 2.99 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
2.99
|
||||
```
|
||||
|
||||
In this example, `product_price` is defined, so the default value is not used.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% assign product_price = 4.99 %}
|
||||
{{ product_price | default: 2.99 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
4.99
|
||||
```
|
||||
|
||||
In this example, `product_price` is empty, so the default value is used.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% assign product_price = "" %}
|
||||
{{ product_price | default: 2.99 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
2.99
|
||||
```
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
---
|
||||
title: divided_by
|
||||
---
|
||||
|
||||
Divides a number by the specified number.
|
||||
|
||||
The result is rounded down to the nearest integer (that is, the [floor](/filters/floor)).
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ 4 | divided_by: 2 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ 4 | divided_by: 2 }}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ 16 | divided_by: 4 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ 16 | divided_by: 4 }}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ 5 | divided_by: 3 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ 5 | divided_by: 3 }}
|
||||
```
|
||||
@@ -1,25 +0,0 @@
|
||||
---
|
||||
title: downcase
|
||||
---
|
||||
|
||||
Makes each character in a string lowercase. It has no effect on strings which are already all lowercase.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "Parker Moore" | downcase }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "Parker Moore" | downcase }}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "apple" | downcase }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "apple" | downcase }}
|
||||
```
|
||||
@@ -1,25 +0,0 @@
|
||||
---
|
||||
title: escape
|
||||
---
|
||||
|
||||
Escapes a string by replacing characters with escape sequences (so that the string can be used in a URL, for example). It doesn't change strings that don't have anything to escape.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "Have you read 'James & the Giant Peach'?" | escape }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "Have you read 'James & the Giant Peach'?" | escape }}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "Tetsuro Takara" | escape }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "Tetsuro Takara" | escape }}
|
||||
```
|
||||
@@ -1,25 +0,0 @@
|
||||
---
|
||||
title: escape_once
|
||||
---
|
||||
|
||||
Escapes a string without changing existing escaped entities. It doesn't change strings that don't have anything to escape.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "1 < 2 & 3" | escape_once }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "1 < 2 & 3" | escape_once }}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "1 < 2 & 3" | escape_once }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "1 < 2 & 3" | escape_once }}
|
||||
```
|
||||
@@ -1,33 +0,0 @@
|
||||
---
|
||||
title: first
|
||||
---
|
||||
|
||||
Returns the first item of an array.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}
|
||||
|
||||
{{ my_array.first }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}
|
||||
|
||||
{{ my_array.first }}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% assign my_array = "zebra, octopus, giraffe, tiger" | split: ", " %}
|
||||
|
||||
{{ my_array.first }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{% assign my_array = "zebra, octopus, giraffe, tiger" | split: ", " %}
|
||||
|
||||
{{ my_array.first }}
|
||||
```
|
||||
@@ -1,47 +0,0 @@
|
||||
---
|
||||
title: floor
|
||||
---
|
||||
|
||||
Rounds a number down to the nearest whole number. Liquid tries to convert the input to a number before the filter is applied.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ 1.2 | floor }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ 1.2 | floor }}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ 2.0 | floor }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ 2.0 | floor }}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ 183.357 | floor }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ 183.357 | floor }}
|
||||
```
|
||||
|
||||
Here the input value is a string:
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "3.5" | floor }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "3.5" | floor }}
|
||||
```
|
||||
@@ -1,10 +0,0 @@
|
||||
---
|
||||
layout: default
|
||||
---
|
||||
|
||||
{% for doc in site.collections["filters"].docs %}
|
||||
<h2 id="{{ doc.title | slugify }}">{{ doc.title }}</h2>
|
||||
<div class="content">
|
||||
{{ doc.content }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
@@ -1,19 +0,0 @@
|
||||
---
|
||||
title: join
|
||||
---
|
||||
|
||||
Combines the items in an array into a single string using the argument as a separator.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}
|
||||
|
||||
{{ beatles | join: " and " }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}
|
||||
|
||||
{{ beatles | join: " and " }}
|
||||
```
|
||||
@@ -1,33 +0,0 @@
|
||||
---
|
||||
title: last
|
||||
---
|
||||
|
||||
Returns the last item of an array.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}
|
||||
|
||||
{{ my_array.last }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}
|
||||
|
||||
{{ my_array.last }}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% assign my_array = "zebra, octopus, giraffe, tiger" | split: ", " %}
|
||||
|
||||
{{ my_array.last }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{% assign my_array = "zebra, octopus, giraffe, tiger" | split: ", " %}
|
||||
|
||||
{{ my_array.last }}
|
||||
```
|
||||
@@ -1,15 +0,0 @@
|
||||
---
|
||||
title: lstrip
|
||||
---
|
||||
|
||||
Removes all whitespaces (tabs, spaces, and newlines) from the beginning of a string. The filter does not affect spaces between words.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ " So much room for activities! " | lstrip }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ " So much room for activities! " | lstrip }}
|
||||
```
|
||||
@@ -1,25 +0,0 @@
|
||||
---
|
||||
title: map
|
||||
---
|
||||
|
||||
Creates an array of values by extracting the values of a named property from another object.
|
||||
|
||||
In this example, assume the object `site.pages` contains all the metadata for a website. Using `assign` with the `map` filter creates a variable that contains only the values of the `category` properties of everything in the `site.pages` object.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% assign all_categories = site.pages | map: "category" %}
|
||||
|
||||
{% for item in all_categories %}
|
||||
{{ item }}
|
||||
{% endfor %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
business
|
||||
celebrities
|
||||
lifestyle
|
||||
sports
|
||||
technology
|
||||
```
|
||||
@@ -1,35 +0,0 @@
|
||||
---
|
||||
title: minus
|
||||
---
|
||||
|
||||
Subtracts a number from another number.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ 4 | minus: 2 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ 4 | minus: 2 }}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ 16 | minus: 4 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ 16 | minus: 4 }}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ 183.357 | minus: 12 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ 183.357 | minus: 12 }}
|
||||
```
|
||||
@@ -1,35 +0,0 @@
|
||||
---
|
||||
title: modulo
|
||||
---
|
||||
|
||||
Returns the remainder of a division operation.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ 3 | modulo: 2 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ 3 | modulo: 2 }}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ 24 | modulo: 7 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ 24 | modulo: 7 }}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ 183.357 | modulo: 12 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ 183.357 | modulo: 12 }}
|
||||
```
|
||||
@@ -1,25 +0,0 @@
|
||||
---
|
||||
title: newline_to_br
|
||||
---
|
||||
|
||||
Replaces every newline (`\n`) with an HTML line break (`<br>`).
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% capture string_with_newlines %}
|
||||
Hello
|
||||
there
|
||||
{% endcapture %}
|
||||
|
||||
{{ string_with_newlines | newline_to_br }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```html
|
||||
{% capture string_with_newlines %}
|
||||
Hello
|
||||
there
|
||||
{% endcapture %}
|
||||
|
||||
{{ string_with_newlines | newline_to_br }}
|
||||
```
|
||||
@@ -1,35 +0,0 @@
|
||||
---
|
||||
title: plus
|
||||
---
|
||||
|
||||
Adds a number to another number.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ 4 | plus: 2 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ 4 | plus: 2 }}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ 16 | plus: 4 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ 16 | plus: 4 }}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ 183.357 | plus: 12 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ 183.357 | plus: 12 }}
|
||||
```
|
||||
@@ -1,31 +0,0 @@
|
||||
---
|
||||
title: prepend
|
||||
---
|
||||
|
||||
Adds the specified string to the beginning of another string.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "apples, oranges, and bananas" | prepend: "Some fruit: " }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "apples, oranges, and bananas" | prepend: "Some fruit: " }}
|
||||
```
|
||||
|
||||
You can also `prepend` variables:
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% assign url = "liquidmarkup.com" %}
|
||||
|
||||
{{ "/index.html" | prepend: url }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{% assign url = "liquidmarkup.com" %}
|
||||
|
||||
{{ "/index.html" | prepend: url }}
|
||||
```
|
||||
@@ -1,15 +0,0 @@
|
||||
---
|
||||
title: remove
|
||||
---
|
||||
|
||||
Removes every occurrence of the specified substring from a string.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "I strained to see the train through the rain" | remove: "rain" }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "I strained to see the train through the rain" | remove: "rain" }}
|
||||
```
|
||||
@@ -1,15 +0,0 @@
|
||||
---
|
||||
title: remove_first
|
||||
---
|
||||
|
||||
Removes only the first occurrence of the specified substring from a string.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "I strained to see the train through the rain" | remove_first: "rain" }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "I strained to see the train through the rain" | remove_first: "rain" }}
|
||||
```
|
||||
@@ -1,15 +0,0 @@
|
||||
---
|
||||
title: replace
|
||||
---
|
||||
|
||||
Replaces every occurrence of an argument in a string with the second argument.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "Take my protein pills and put my helmet on" | replace: "my", "your" }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "Take my protein pills and put my helmet on" | replace: "my", "your" }}
|
||||
```
|
||||
@@ -1,17 +0,0 @@
|
||||
---
|
||||
title: replace_first
|
||||
---
|
||||
|
||||
Replaces only the first occurrence of the first argument in a string with the second argument.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% assign my_string = "Take my protein pills and put my helmet on" %}
|
||||
{{ my_string | replace_first: "my", "your" }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{% assign my_string = "Take my protein pills and put my helmet on" %}
|
||||
{{ my_string | replace_first: "my", "your" }}
|
||||
```
|
||||
@@ -1,31 +0,0 @@
|
||||
---
|
||||
title: reverse
|
||||
---
|
||||
|
||||
Reverses the order of the items in an array. `reverse` cannot reverse a string.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}
|
||||
|
||||
{{ my_array | reverse | join: ", " }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}
|
||||
|
||||
{{ my_array | reverse | join: ", " }}
|
||||
```
|
||||
|
||||
`reverse` cannot be used directly on a string, but you can split a string into an array, reverse the array, and rejoin it by chaining together filters:
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "Ground control to Major Tom." | split: "" | reverse | join: "" }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "Ground control to Major Tom." | split: "" | reverse | join: "" }}
|
||||
```
|
||||
@@ -1,35 +0,0 @@
|
||||
---
|
||||
title: round
|
||||
---
|
||||
|
||||
Rounds an input number to the nearest integer or, if a number is specified as an argument, to that number of decimal places.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ 1.2 | round }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ 1.2 | round }}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ 2.7 | round }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ 2.7 | round }}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ 183.357 | round: 2 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ 183.357 | round: 2 }}
|
||||
```
|
||||
@@ -1,15 +0,0 @@
|
||||
---
|
||||
title: rstrip
|
||||
---
|
||||
|
||||
Removes all whitespace (tabs, spaces, and newlines) from the right side of a string.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ " So much room for activities! " | rstrip }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ " So much room for activities! " | rstrip }}
|
||||
```
|
||||
@@ -1,39 +0,0 @@
|
||||
---
|
||||
title: size
|
||||
---
|
||||
|
||||
Returns the number of characters in a string or the number of items in an array. `size` can also be used with dot notation (for example, `{% raw %}{{ my_string.size }}{% endraw %}`). This allows you to use `size` inside tags such as conditionals.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "Ground control to Major Tom." | size }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "Ground control to Major Tom." | size }}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}
|
||||
|
||||
{{ my_array | size }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{% assign my_array = "apples, oranges, peaches, plums" | split: ", " %}
|
||||
|
||||
{{ my_array | size }}
|
||||
```
|
||||
|
||||
Using dot notation:
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% if site.pages.size > 10 %}
|
||||
This is a big website!
|
||||
{% endif %}
|
||||
{% endraw %}
|
||||
```
|
||||
@@ -1,49 +0,0 @@
|
||||
---
|
||||
title: slice
|
||||
---
|
||||
|
||||
Returns a substring of 1 character beginning at the index specified by the argument passed in. An optional second argument specifies the length of the substring to be returned.
|
||||
|
||||
String indices are numbered starting from 0.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "Liquid" | slice: 0 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "Liquid" | slice: 0 }}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "Liquid" | slice: 2 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "Liquid" | slice: 2 }}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "Liquid" | slice: 2, 5 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "Liquid" | slice: 2, 5 }}
|
||||
```
|
||||
|
||||
If the first parameter is a negative number, the indices are counted from the end of the string:
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "Liquid" | slice: -3, 2 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "Liquid" | slice: -3, 2 }}
|
||||
```
|
||||
@@ -1,19 +0,0 @@
|
||||
---
|
||||
title: sort
|
||||
---
|
||||
|
||||
Sorts items in an array by a property of an item in the array. The order of the sorted array is case-sensitive.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% assign my_array = "zebra, octopus, giraffe, Sally Snake" | split: ", " %}
|
||||
|
||||
{{ my_array | sort | join: ", " }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{% assign my_array = "zebra, octopus, giraffe, Sally Snake" | split: ", " %}
|
||||
|
||||
{{ my_array | sort | join: ", " }}
|
||||
```
|
||||
@@ -1,23 +0,0 @@
|
||||
---
|
||||
title: split
|
||||
---
|
||||
|
||||
Divides an input string into an array using the argument as a separator. `split` is commonly used to convert comma-separated items from a string to an array.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}
|
||||
|
||||
{% for member in beatles %}
|
||||
{{ member }}
|
||||
{% endfor %}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}
|
||||
|
||||
{% for member in beatles %}
|
||||
{{ member }}
|
||||
{% endfor %}
|
||||
```
|
||||
@@ -1,15 +0,0 @@
|
||||
---
|
||||
title: strip
|
||||
---
|
||||
|
||||
Removes all whitespace (tabs, spaces, and newlines) from both the left and right side of a string. It does not affect spaces between words.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ " So much room for activities! " | strip }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ " So much room for activities! " | strip }}
|
||||
```
|
||||
@@ -1,15 +0,0 @@
|
||||
---
|
||||
title: strip_html
|
||||
---
|
||||
|
||||
Removes any HTML tags from a string.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "Have <em>you</em> read <strong>Ulysses</strong>?" | strip_html }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "Have <em>you</em> read <strong>Ulysses</strong>?" | strip_html }}
|
||||
```
|
||||
@@ -1,26 +0,0 @@
|
||||
---
|
||||
title: strip_newlines
|
||||
---
|
||||
|
||||
Removes any newline characters (line breaks) from a string.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% capture string_with_newlines %}
|
||||
Hello
|
||||
there
|
||||
{% endcapture %}
|
||||
|
||||
{{ string_with_newlines | strip_newlines }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```html
|
||||
{% capture string_with_newlines %}
|
||||
Hello
|
||||
there
|
||||
{% endcapture %}
|
||||
|
||||
{{ string_with_newlines | strip_newlines }}
|
||||
```
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
---
|
||||
title: times
|
||||
---
|
||||
|
||||
Multiplies a number by another number.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ 3 | times: 2 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ 3 | times: 2 }}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ 24 | times: 7 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ 24 | times: 7 }}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ 183.357 | times: 12 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ 183.357 | times: 12 }}
|
||||
```
|
||||
@@ -1,15 +0,0 @@
|
||||
---
|
||||
title: truncate
|
||||
---
|
||||
|
||||
`truncate` shortens a string down to the number of characters passed as a parameter. If the number of characters specified is less than the length of the string, an ellipsis (...) is appended to the string and is included in the character count.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "Ground control to Major Tom." | truncate: 20 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "Ground control to Major Tom." | truncate: 20 }}
|
||||
```
|
||||
@@ -1,15 +0,0 @@
|
||||
---
|
||||
title: truncatewords
|
||||
---
|
||||
|
||||
Shortens a string down to the number of words passed as the argument. If the specified number of words is less than the number of words in the string, an ellipsis (...) is appended to the string.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "Ground control to Major Tom." | truncatewords: 3 }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "Ground control to Major Tom." | truncatewords: 3 }}
|
||||
```
|
||||
@@ -1,19 +0,0 @@
|
||||
---
|
||||
title: uniq
|
||||
---
|
||||
|
||||
Removes any duplicate elements in an array.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{% assign my_array = "ants, bugs, bees, bugs, ants" | split: ", " %}
|
||||
|
||||
{{ my_array | uniq | join: ", " }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{% assign my_array = "ants, bugs, bees, bugs, ants" | split: ", " %}
|
||||
|
||||
{{ my_array | uniq | join: ", " }}
|
||||
```
|
||||
@@ -1,25 +0,0 @@
|
||||
---
|
||||
title: upcase
|
||||
---
|
||||
|
||||
Makes each character in a string uppercase. It has no effect on strings which are already all uppercase.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "Parker Moore" | upcase }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "Parker Moore" | upcase }}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "APPLE" | upcase }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "APPLE" | upcase }}
|
||||
```
|
||||
@@ -1,25 +0,0 @@
|
||||
---
|
||||
title: url_encode
|
||||
---
|
||||
|
||||
Converts any URL-unsafe characters in a string into percent-encoded characters.
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "john@liquid.com" | url_encode }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "john@liquid.com" | url_encode }}
|
||||
```
|
||||
|
||||
```liquid
|
||||
{% raw %}
|
||||
{{ "Tetsuro Takara" | url_encode }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
```text
|
||||
{{ "Tetsuro Takara" | url_encode }}
|
||||
```
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 20 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 30 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 27 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 18 KiB |
@@ -1,16 +0,0 @@
|
||||
---
|
||||
layout: default
|
||||
---
|
||||
|
||||
{% include home-banner.html %}
|
||||
|
||||
## What is Liquid?
|
||||
|
||||
Liquid is an open-source template language created by [Shopify](https://www.shopify.com) and written in Ruby. It is the backbone of Shopify themes and is used to load dynamic content on storefronts.
|
||||
|
||||
Liquid has been in production use since June 2006 and is now used by many other hosted web applications.
|
||||
|
||||
## Who uses Liquid?
|
||||
|
||||
{% include home-users-grid.html %}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
require 'liquid'
|
||||
require 'extras/liquid_view'
|
||||
|
||||
if defined? ActionView::Template and ActionView::Template.respond_to? :register_template_handler
|
||||
ActionView::Template
|
||||
else
|
||||
ActionView::Base
|
||||
end.register_template_handler(:liquid, LiquidView)
|
||||
@@ -0,0 +1,51 @@
|
||||
# LiquidView is a action view extension class. You can register it with rails
|
||||
# and use liquid as an template system for .liquid files
|
||||
#
|
||||
# Example
|
||||
#
|
||||
# ActionView::Base::register_template_handler :liquid, LiquidView
|
||||
class LiquidView
|
||||
PROTECTED_ASSIGNS = %w( template_root response _session template_class action_name request_origin session template
|
||||
_response url _request _cookies variables_added _flash params _headers request cookies
|
||||
ignore_missing_templates flash _params logger before_filter_chain_aborted headers )
|
||||
PROTECTED_INSTANCE_VARIABLES = %w( @_request @controller @_first_render @_memoized__pick_template @view_paths
|
||||
@helpers @assigns_added @template @_render_stack @template_format @assigns )
|
||||
|
||||
def self.call(template)
|
||||
"LiquidView.new(self).render(template, local_assigns)"
|
||||
end
|
||||
|
||||
def initialize(view)
|
||||
@view = view
|
||||
end
|
||||
|
||||
def render(template, local_assigns = nil)
|
||||
@view.controller.headers["Content-Type"] ||= 'text/html; charset=utf-8'
|
||||
|
||||
# Rails 2.2 Template has source, but not locals
|
||||
if template.respond_to?(:source) && !template.respond_to?(:locals)
|
||||
assigns = (@view.instance_variables - PROTECTED_INSTANCE_VARIABLES).inject({}) do |hash, ivar|
|
||||
hash[ivar[1..-1]] = @view.instance_variable_get(ivar)
|
||||
hash
|
||||
end
|
||||
else
|
||||
assigns = @view.assigns.reject{ |k,v| PROTECTED_ASSIGNS.include?(k) }
|
||||
end
|
||||
|
||||
source = template.respond_to?(:source) ? template.source : template
|
||||
local_assigns = (template.respond_to?(:locals) ? template.locals : local_assigns) || {}
|
||||
|
||||
if content_for_layout = @view.instance_variable_get("@content_for_layout")
|
||||
assigns['content_for_layout'] = content_for_layout
|
||||
end
|
||||
assigns.merge!(local_assigns.stringify_keys)
|
||||
|
||||
liquid = Liquid::Template.parse(source)
|
||||
liquid.render(assigns, :filters => [@view.controller.master_helper_module], :registers => {:action_view => @view, :controller => @view.controller})
|
||||
end
|
||||
|
||||
def compilable?
|
||||
false
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,69 @@
|
||||
# Copyright (c) 2005 Tobias Luetke
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
module Liquid
|
||||
FilterSeparator = /\|/
|
||||
ArgumentSeparator = ','
|
||||
FilterArgumentSeparator = ':'
|
||||
VariableAttributeSeparator = '.'
|
||||
TagStart = /\{\%/
|
||||
TagEnd = /\%\}/
|
||||
VariableSignature = /\(?[\w\-\.\[\]]\)?/
|
||||
VariableSegment = /[\w\-]/
|
||||
VariableStart = /\{\{/
|
||||
VariableEnd = /\}\}/
|
||||
VariableIncompleteEnd = /\}\}?/
|
||||
QuotedString = /"[^"]*"|'[^']*'/
|
||||
QuotedFragment = /#{QuotedString}|(?:[^\s,\|'"]|#{QuotedString})+/o
|
||||
StrictQuotedFragment = /"[^"]+"|'[^']+'|[^\s|:,]+/
|
||||
FirstFilterArgument = /#{FilterArgumentSeparator}(?:#{StrictQuotedFragment})/o
|
||||
OtherFilterArgument = /#{ArgumentSeparator}(?:#{StrictQuotedFragment})/o
|
||||
SpacelessFilter = /^(?:'[^']+'|"[^"]+"|[^'"])*#{FilterSeparator}(?:#{StrictQuotedFragment})(?:#{FirstFilterArgument}(?:#{OtherFilterArgument})*)?/o
|
||||
Expression = /(?:#{QuotedFragment}(?:#{SpacelessFilter})*)/o
|
||||
TagAttributes = /(\w+)\s*\:\s*(#{QuotedFragment})/o
|
||||
AnyStartingTag = /\{\{|\{\%/
|
||||
PartialTemplateParser = /#{TagStart}.*?#{TagEnd}|#{VariableStart}.*?#{VariableIncompleteEnd}/o
|
||||
TemplateParser = /(#{PartialTemplateParser}|#{AnyStartingTag})/o
|
||||
VariableParser = /\[[^\]]+\]|#{VariableSegment}+\??/o
|
||||
end
|
||||
|
||||
require 'liquid/drop'
|
||||
require 'liquid/extensions'
|
||||
require 'liquid/errors'
|
||||
require 'liquid/interrupts'
|
||||
require 'liquid/strainer'
|
||||
require 'liquid/context'
|
||||
require 'liquid/tag'
|
||||
require 'liquid/block'
|
||||
require 'liquid/document'
|
||||
require 'liquid/variable'
|
||||
require 'liquid/file_system'
|
||||
require 'liquid/template'
|
||||
require 'liquid/htmltags'
|
||||
require 'liquid/standardfilters'
|
||||
require 'liquid/condition'
|
||||
require 'liquid/module_ex'
|
||||
require 'liquid/utils'
|
||||
require 'liquid_ext'
|
||||
|
||||
# Load all the tags of the standard library
|
||||
#
|
||||
Dir[File.dirname(__FILE__) + '/liquid/tags/*.rb'].each { |f| require f }
|
||||
@@ -0,0 +1,115 @@
|
||||
module Liquid
|
||||
|
||||
class Block < Tag
|
||||
IsTag = /^#{TagStart}/o
|
||||
IsVariable = /^#{VariableStart}/o
|
||||
FullToken = /^#{TagStart}\s*(\w+)\s*(.*)?#{TagEnd}$/o
|
||||
ContentOfVariable = /^#{VariableStart}(.*)#{VariableEnd}$/o
|
||||
|
||||
def parse(tokens)
|
||||
@nodelist ||= []
|
||||
@nodelist.clear
|
||||
|
||||
while token = tokens.shift
|
||||
|
||||
case token
|
||||
when IsTag
|
||||
if token =~ FullToken
|
||||
|
||||
# if we found the proper block delimitor just end parsing here and let the outer block
|
||||
# proceed
|
||||
if block_delimiter == $1
|
||||
end_tag
|
||||
return
|
||||
end
|
||||
|
||||
# fetch the tag from registered blocks
|
||||
if tag = Template.tags[$1]
|
||||
@nodelist << tag.new($1, $2, tokens)
|
||||
else
|
||||
# this tag is not registered with the system
|
||||
# pass it to the current block for special handling or error reporting
|
||||
unknown_tag($1, $2, tokens)
|
||||
end
|
||||
else
|
||||
raise SyntaxError, "Tag '#{token}' was not properly terminated with regexp: #{TagEnd.inspect} "
|
||||
end
|
||||
when IsVariable
|
||||
@nodelist << create_variable(token)
|
||||
when ''
|
||||
# pass
|
||||
else
|
||||
@nodelist << token
|
||||
end
|
||||
end
|
||||
|
||||
# Make sure that its ok to end parsing in the current block.
|
||||
# Effectively this method will throw and exception unless the current block is
|
||||
# of type Document
|
||||
assert_missing_delimitation!
|
||||
end
|
||||
|
||||
def end_tag
|
||||
end
|
||||
|
||||
def unknown_tag(tag, params, tokens)
|
||||
case tag
|
||||
when 'else'
|
||||
raise SyntaxError, "#{block_name} tag does not expect else tag"
|
||||
when 'end'
|
||||
raise SyntaxError, "'end' is not a valid delimiter for #{block_name} tags. use #{block_delimiter}"
|
||||
else
|
||||
raise SyntaxError, "Unknown tag '#{tag}'"
|
||||
end
|
||||
end
|
||||
|
||||
def block_delimiter
|
||||
"end#{block_name}"
|
||||
end
|
||||
|
||||
def block_name
|
||||
@tag_name
|
||||
end
|
||||
|
||||
def create_variable(token)
|
||||
token.scan(ContentOfVariable) do |content|
|
||||
return Variable.new(content.first)
|
||||
end
|
||||
raise SyntaxError.new("Variable '#{token}' was not properly terminated with regexp: #{VariableEnd.inspect} ")
|
||||
end
|
||||
|
||||
def render(context)
|
||||
render_all(@nodelist, context)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def assert_missing_delimitation!
|
||||
raise SyntaxError.new("#{block_name} tag was never closed")
|
||||
end
|
||||
|
||||
def render_all(list, context)
|
||||
output = []
|
||||
list.each do |token|
|
||||
# Break out if we have any unhanded interrupts.
|
||||
break if context.has_interrupt?
|
||||
|
||||
begin
|
||||
# If we get an Interrupt that means the block must stop processing. An
|
||||
# Interrupt is any command that stops block execution such as {% break %}
|
||||
# or {% continue %}
|
||||
if token.is_a? Continue or token.is_a? Break
|
||||
context.push_interrupt(token.interrupt)
|
||||
break
|
||||
end
|
||||
|
||||
output << (token.respond_to?(:render) ? token.render(context) : token)
|
||||
rescue ::StandardError => e
|
||||
output << (context.handle_error(e))
|
||||
end
|
||||
end
|
||||
|
||||
output
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,120 @@
|
||||
module Liquid
|
||||
# Container for liquid nodes which conveniently wraps decision making logic
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# c = Condition.new('1', '==', '1')
|
||||
# c.evaluate #=> true
|
||||
#
|
||||
class Condition #:nodoc:
|
||||
@@operators = {
|
||||
'==' => lambda { |cond, left, right| cond.send(:equal_variables, left, right) },
|
||||
'!=' => lambda { |cond, left, right| !cond.send(:equal_variables, left, right) },
|
||||
'<>' => lambda { |cond, left, right| !cond.send(:equal_variables, left, right) },
|
||||
'<' => :<,
|
||||
'>' => :>,
|
||||
'>=' => :>=,
|
||||
'<=' => :<=,
|
||||
'contains' => lambda { |cond, left, right| left && right ? left.include?(right) : false }
|
||||
}
|
||||
|
||||
def self.operators
|
||||
@@operators
|
||||
end
|
||||
|
||||
attr_reader :attachment
|
||||
attr_accessor :left, :operator, :right
|
||||
|
||||
def initialize(left = nil, operator = nil, right = nil)
|
||||
@left, @operator, @right = left, operator, right
|
||||
@child_relation = nil
|
||||
@child_condition = nil
|
||||
end
|
||||
|
||||
def evaluate(context = Context.new)
|
||||
result = interpret_condition(left, right, operator, context)
|
||||
|
||||
case @child_relation
|
||||
when :or
|
||||
result || @child_condition.evaluate(context)
|
||||
when :and
|
||||
result && @child_condition.evaluate(context)
|
||||
else
|
||||
result
|
||||
end
|
||||
end
|
||||
|
||||
def or(condition)
|
||||
@child_relation, @child_condition = :or, condition
|
||||
end
|
||||
|
||||
def and(condition)
|
||||
@child_relation, @child_condition = :and, condition
|
||||
end
|
||||
|
||||
def attach(attachment)
|
||||
@attachment = attachment
|
||||
end
|
||||
|
||||
def else?
|
||||
false
|
||||
end
|
||||
|
||||
def inspect
|
||||
"#<Condition #{[@left, @operator, @right].compact.join(' ')}>"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def equal_variables(left, right)
|
||||
if left.is_a?(Symbol)
|
||||
if right.respond_to?(left)
|
||||
return right.send(left.to_s)
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
if right.is_a?(Symbol)
|
||||
if left.respond_to?(right)
|
||||
return left.send(right.to_s)
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
left == right
|
||||
end
|
||||
|
||||
def interpret_condition(left, right, op, context)
|
||||
# If the operator is empty this means that the decision statement is just
|
||||
# a single variable. We can just poll this variable from the context and
|
||||
# return this as the result.
|
||||
return context[left] if op == nil
|
||||
|
||||
left, right = context[left], context[right]
|
||||
|
||||
operation = self.class.operators[op] || raise(ArgumentError.new("Unknown operator #{op}"))
|
||||
|
||||
if operation.respond_to?(:call)
|
||||
operation.call(self, left, right)
|
||||
elsif left.respond_to?(operation) and right.respond_to?(operation)
|
||||
left.send(operation, right)
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
class ElseCondition < Condition
|
||||
def else?
|
||||
true
|
||||
end
|
||||
|
||||
def evaluate(context)
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,262 @@
|
||||
module Liquid
|
||||
|
||||
|
||||
# Context keeps the variable stack and resolves variables, as well as keywords
|
||||
#
|
||||
# context['variable'] = 'testing'
|
||||
# context['variable'] #=> 'testing'
|
||||
# context['true'] #=> true
|
||||
# context['10.2232'] #=> 10.2232
|
||||
#
|
||||
# context.stack do
|
||||
# context['bob'] = 'bobsen'
|
||||
# end
|
||||
#
|
||||
# context['bob'] #=> nil class Context
|
||||
class Context
|
||||
attr_reader :scopes, :errors, :registers, :environments
|
||||
|
||||
def initialize(environments = {}, outer_scope = {}, registers = {}, rethrow_errors = false)
|
||||
@environments = [environments].flatten
|
||||
@scopes = [(outer_scope || {})]
|
||||
@registers = registers
|
||||
@errors = []
|
||||
@rethrow_errors = rethrow_errors
|
||||
squash_instance_assigns_with_environments
|
||||
|
||||
@interrupts = []
|
||||
end
|
||||
|
||||
def strainer
|
||||
@strainer ||= Strainer.create(self)
|
||||
end
|
||||
|
||||
# Adds filters to this context.
|
||||
#
|
||||
# Note that this does not register the filters with the main Template object. see <tt>Template.register_filter</tt>
|
||||
# for that
|
||||
def add_filters(filters)
|
||||
filters = [filters].flatten.compact
|
||||
|
||||
filters.each do |f|
|
||||
raise ArgumentError, "Expected module but got: #{f.class}" unless f.is_a?(Module)
|
||||
strainer.extend(f)
|
||||
end
|
||||
end
|
||||
|
||||
# are there any not handled interrupts?
|
||||
def has_interrupt?
|
||||
!@interrupts.empty?
|
||||
end
|
||||
|
||||
# push an interrupt to the stack. this interrupt is considered not handled.
|
||||
def push_interrupt(e)
|
||||
@interrupts.push(e)
|
||||
end
|
||||
|
||||
# pop an interrupt from the stack
|
||||
def pop_interrupt
|
||||
@interrupts.pop
|
||||
end
|
||||
|
||||
def handle_error(e)
|
||||
errors.push(e)
|
||||
raise if @rethrow_errors
|
||||
|
||||
case e
|
||||
when SyntaxError
|
||||
"Liquid syntax error: #{e.message}"
|
||||
else
|
||||
"Liquid error: #{e.message}"
|
||||
end
|
||||
end
|
||||
|
||||
def invoke(method, *args)
|
||||
if strainer.respond_to?(method)
|
||||
strainer.__send__(method, *args)
|
||||
else
|
||||
args.first
|
||||
end
|
||||
end
|
||||
|
||||
# Push new local scope on the stack. use <tt>Context#stack</tt> instead
|
||||
def push(new_scope={})
|
||||
@scopes.unshift(new_scope)
|
||||
raise StackLevelError, "Nesting too deep" if @scopes.length > 100
|
||||
end
|
||||
|
||||
# Merge a hash of variables in the current local scope
|
||||
def merge(new_scopes)
|
||||
@scopes[0].merge!(new_scopes)
|
||||
end
|
||||
|
||||
# Pop from the stack. use <tt>Context#stack</tt> instead
|
||||
def pop
|
||||
raise ContextError if @scopes.size == 1
|
||||
@scopes.shift
|
||||
end
|
||||
|
||||
# Pushes a new local scope on the stack, pops it at the end of the block
|
||||
#
|
||||
# Example:
|
||||
# context.stack do
|
||||
# context['var'] = 'hi'
|
||||
# end
|
||||
#
|
||||
# context['var] #=> nil
|
||||
def stack(new_scope={})
|
||||
push(new_scope)
|
||||
yield
|
||||
ensure
|
||||
pop
|
||||
end
|
||||
|
||||
def clear_instance_assigns
|
||||
@scopes[0] = {}
|
||||
end
|
||||
|
||||
|
||||
# Look up variable, either resolve directly after considering the name. We can directly handle
|
||||
# Strings, digits, floats and booleans (true,false).
|
||||
# If no match is made we lookup the variable in the current scope and
|
||||
# later move up to the parent blocks to see if we can resolve the variable somewhere up the tree.
|
||||
# Some special keywords return symbols. Those symbols are to be called on the rhs object in expressions
|
||||
#
|
||||
# Example:
|
||||
# products == empty #=> products.empty?
|
||||
def resolve(key)
|
||||
case key
|
||||
when nil, ""
|
||||
return nil
|
||||
when "blank"
|
||||
return :blank?
|
||||
when "empty"
|
||||
return :empty?
|
||||
end
|
||||
|
||||
result = Parser.parse(key)
|
||||
stack = []
|
||||
|
||||
result.each do |(sym, value)|
|
||||
|
||||
case sym
|
||||
when :id
|
||||
stack.push value
|
||||
when :lookup
|
||||
left = stack.pop
|
||||
value = find_variable(left)
|
||||
|
||||
stack.push(harden(value))
|
||||
when :range
|
||||
right = stack.pop.to_i
|
||||
left = stack.pop.to_i
|
||||
|
||||
stack.push (left..right)
|
||||
when :buildin
|
||||
left = stack.pop
|
||||
value = invoke_buildin(left, value)
|
||||
|
||||
stack.push(harden(value))
|
||||
when :call
|
||||
left = stack.pop
|
||||
right = stack.pop
|
||||
value = lookup_and_evaluate(right, left)
|
||||
|
||||
stack.push(harden(value))
|
||||
else
|
||||
raise "unknown #{sym}"
|
||||
end
|
||||
end
|
||||
|
||||
return stack.first
|
||||
end
|
||||
|
||||
|
||||
# Only allow String, Numeric, Hash, Array, Proc, Boolean or <tt>Liquid::Drop</tt>
|
||||
def []=(key, value)
|
||||
@scopes[0][key] = value
|
||||
end
|
||||
|
||||
def has_key?(key)
|
||||
resolve(key) != nil
|
||||
end
|
||||
|
||||
alias_method :[], :resolve
|
||||
|
||||
private
|
||||
|
||||
def invoke_buildin(obj, key)
|
||||
# as weird as this is, liquid unit tests demand that we prioritize hash lookups
|
||||
# to buildins. So if we got a hash and it has a :first element we need to call that
|
||||
# instead of sending the first message...
|
||||
|
||||
if obj.respond_to?(:has_key?) && obj.has_key?(key)
|
||||
return lookup_and_evaluate(obj, key)
|
||||
end
|
||||
|
||||
if obj.respond_to?(key)
|
||||
return obj.send(key)
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
# Fetches an object starting at the local scope and then moving up the hierachy
|
||||
def find_variable(key)
|
||||
scope = @scopes.find { |s| s.has_key?(key) }
|
||||
|
||||
if scope.nil?
|
||||
@environments.each do |e|
|
||||
if variable = lookup_and_evaluate(e, key)
|
||||
scope = e
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
scope ||= @environments.last || @scopes.last
|
||||
variable ||= lookup_and_evaluate(scope, key)
|
||||
|
||||
return variable
|
||||
end
|
||||
|
||||
def lookup_and_evaluate(obj, key)
|
||||
return nil unless obj.respond_to?(:[])
|
||||
|
||||
if obj.is_a?(Array)
|
||||
return nil unless key.is_a?(Integer)
|
||||
end
|
||||
|
||||
value = obj[key]
|
||||
|
||||
if value.is_a?(Proc)
|
||||
# call the proc
|
||||
value = (value.arity == 0) ? value.call : value.call(self)
|
||||
|
||||
# memozie if possible
|
||||
obj[key] = value if obj.respond_to?(:[]=)
|
||||
end
|
||||
|
||||
value
|
||||
end
|
||||
|
||||
def harden(value)
|
||||
value = value.to_liquid
|
||||
value.context = self if value.respond_to?(:context=)
|
||||
return value
|
||||
end
|
||||
|
||||
def squash_instance_assigns_with_environments
|
||||
@scopes.last.each_key do |k|
|
||||
@environments.each do |env|
|
||||
if env.has_key?(k)
|
||||
scopes.last[k] = lookup_and_evaluate(env, k)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end # squash_instance_assigns_with_environments
|
||||
|
||||
end # Context
|
||||
|
||||
end # Liquid
|
||||
@@ -0,0 +1,17 @@
|
||||
module Liquid
|
||||
class Document < Block
|
||||
# we don't need markup to open this block
|
||||
def initialize(tokens)
|
||||
parse(tokens)
|
||||
end
|
||||
|
||||
# There isn't a real delimter
|
||||
def block_delimiter
|
||||
[]
|
||||
end
|
||||
|
||||
# Document blocks don't need to be terminated since they are not actually opened
|
||||
def assert_missing_delimitation!
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,51 @@
|
||||
module Liquid
|
||||
|
||||
# A drop in liquid is a class which allows you to export DOM like things to liquid.
|
||||
# Methods of drops are callable.
|
||||
# The main use for liquid drops is to implement lazy loaded objects.
|
||||
# If you would like to make data available to the web designers which you don't want loaded unless needed then
|
||||
# a drop is a great way to do that.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# class ProductDrop < Liquid::Drop
|
||||
# def top_sales
|
||||
# Shop.current.products.find(:all, :order => 'sales', :limit => 10 )
|
||||
# end
|
||||
# end
|
||||
#
|
||||
# tmpl = Liquid::Template.parse( ' {% for product in product.top_sales %} {{ product.name }} {%endfor%} ' )
|
||||
# tmpl.render('product' => ProductDrop.new ) # will invoke top_sales query.
|
||||
#
|
||||
# Your drop can either implement the methods sans any parameters or implement the before_method(name) method which is a
|
||||
# catch all.
|
||||
class Drop
|
||||
attr_writer :context
|
||||
|
||||
EMPTY_STRING = ''.freeze
|
||||
|
||||
# Catch all for the method
|
||||
def before_method(method)
|
||||
nil
|
||||
end
|
||||
|
||||
# called by liquid to invoke a drop
|
||||
def invoke_drop(method_or_key)
|
||||
if method_or_key && method_or_key != EMPTY_STRING && self.class.public_method_defined?(method_or_key.to_s.to_sym)
|
||||
send(method_or_key.to_s.to_sym)
|
||||
else
|
||||
before_method(method_or_key)
|
||||
end
|
||||
end
|
||||
|
||||
def has_key?(name)
|
||||
true
|
||||
end
|
||||
|
||||
def to_liquid
|
||||
self
|
||||
end
|
||||
|
||||
alias :[] :invoke_drop
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
module Liquid
|
||||
class Error < ::StandardError; end
|
||||
|
||||
class ArgumentError < Error; end
|
||||
class ContextError < Error; end
|
||||
class FilterNotFound < Error; end
|
||||
class FileSystemError < Error; end
|
||||
class StandardError < Error; end
|
||||
class SyntaxError < Error; end
|
||||
class StackLevelError < Error; end
|
||||
end
|
||||
@@ -0,0 +1,62 @@
|
||||
require 'time'
|
||||
require 'date'
|
||||
|
||||
class String # :nodoc:
|
||||
def to_liquid
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
class Array # :nodoc:
|
||||
def to_liquid
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
class Hash # :nodoc:
|
||||
def to_liquid
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
class Numeric # :nodoc:
|
||||
def to_liquid
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
class Time # :nodoc:
|
||||
def to_liquid
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
class DateTime < Date # :nodoc:
|
||||
def to_liquid
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
class Date # :nodoc:
|
||||
def to_liquid
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
class TrueClass
|
||||
def to_liquid # :nodoc:
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
class FalseClass
|
||||
def to_liquid # :nodoc:
|
||||
self
|
||||
end
|
||||
end
|
||||
|
||||
class NilClass
|
||||
def to_liquid # :nodoc:
|
||||
self
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,62 @@
|
||||
module Liquid
|
||||
# A Liquid file system is way to let your templates retrieve other templates for use with the include tag.
|
||||
#
|
||||
# You can implement subclasses that retrieve templates from the database, from the file system using a different
|
||||
# path structure, you can provide them as hard-coded inline strings, or any manner that you see fit.
|
||||
#
|
||||
# You can add additional instance variables, arguments, or methods as needed.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# Liquid::Template.file_system = Liquid::LocalFileSystem.new(template_path)
|
||||
# liquid = Liquid::Template.parse(template)
|
||||
#
|
||||
# This will parse the template with a LocalFileSystem implementation rooted at 'template_path'.
|
||||
class BlankFileSystem
|
||||
# Called by Liquid to retrieve a template file
|
||||
def read_template_file(template_path, context)
|
||||
raise FileSystemError, "This liquid context does not allow includes."
|
||||
end
|
||||
end
|
||||
|
||||
# This implements an abstract file system which retrieves template files named in a manner similar to Rails partials,
|
||||
# ie. with the template name prefixed with an underscore. The extension ".liquid" is also added.
|
||||
#
|
||||
# For security reasons, template paths are only allowed to contain letters, numbers, and underscore.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# file_system = Liquid::LocalFileSystem.new("/some/path")
|
||||
#
|
||||
# file_system.full_path("mypartial") # => "/some/path/_mypartial.liquid"
|
||||
# file_system.full_path("dir/mypartial") # => "/some/path/dir/_mypartial.liquid"
|
||||
#
|
||||
class LocalFileSystem
|
||||
attr_accessor :root
|
||||
|
||||
def initialize(root)
|
||||
@root = root
|
||||
end
|
||||
|
||||
def read_template_file(template_path, context)
|
||||
full_path = full_path(template_path)
|
||||
raise FileSystemError, "No such template '#{template_path}'" unless File.exists?(full_path)
|
||||
|
||||
File.read(full_path)
|
||||
end
|
||||
|
||||
def full_path(template_path)
|
||||
raise FileSystemError, "Illegal template name '#{template_path}'" unless template_path =~ /^[^.\/][a-zA-Z0-9_\/]+$/
|
||||
|
||||
full_path = if template_path.include?('/')
|
||||
File.join(root, File.dirname(template_path), "_#{File.basename(template_path)}.liquid")
|
||||
else
|
||||
File.join(root, "_#{template_path}.liquid")
|
||||
end
|
||||
|
||||
raise FileSystemError, "Illegal template path '#{File.expand_path(full_path)}'" unless File.expand_path(full_path) =~ /^#{File.expand_path(root)}/
|
||||
|
||||
full_path
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,119 @@
|
||||
module Liquid
|
||||
class TableRow < Block
|
||||
Syntax = /(\w+)\s+in\s+(#{QuotedFragment}+)/o
|
||||
|
||||
def initialize(tag_name, markup, tokens)
|
||||
if markup =~ Syntax
|
||||
@variable_name = $1
|
||||
@collection_name = $2
|
||||
@idx_i = "#{$1}-#{$2}-i"
|
||||
@idx_col = "#{$1}-#{$2}-c"
|
||||
@attributes = {}
|
||||
markup.scan(TagAttributes) do |key, value|
|
||||
@attributes[key] = value
|
||||
end
|
||||
else
|
||||
raise SyntaxError.new("Syntax Error in 'table_row loop' - Valid syntax: table_row [item] in [collection] cols=3")
|
||||
end
|
||||
|
||||
super
|
||||
end
|
||||
|
||||
def render(context)
|
||||
context.registers[:tablerowloop] ||= Hash.new(0)
|
||||
|
||||
collection = context[@collection_name] or return ''
|
||||
|
||||
from = @attributes['offset'] ? context[@attributes['offset']].to_i : 0
|
||||
to = @attributes['limit'] ? from + context[@attributes['limit']].to_i : nil
|
||||
|
||||
collection = Utils.slice_collection_using_each(collection, from, to)
|
||||
|
||||
length = collection.length
|
||||
|
||||
cols = context[@attributes['cols']].to_i
|
||||
|
||||
row = 1
|
||||
col = 0
|
||||
|
||||
result = ["<tr class=\"row1\">\n"]
|
||||
context.stack do
|
||||
|
||||
context.registers[:tablerowloop][@idx]
|
||||
context['tablerowloop'] = lambda { Tablerowloop.new(@idx_i, @idx_col, length) }
|
||||
collection.each_with_index do |item, index|
|
||||
context.registers[:tablerowloop][@idx_i] = index
|
||||
context.registers[:tablerowloop][@idx_col] = col
|
||||
context[@variable_name] = item
|
||||
|
||||
col += 1
|
||||
|
||||
result << "<td class=\"col#{col}\">" << render_all(@nodelist, context) << '</td>'
|
||||
|
||||
if col == cols and not (index == length - 1)
|
||||
col = 0
|
||||
row += 1
|
||||
result << "</tr>\n<tr class=\"row#{row}\">"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
result << "</tr>\n"
|
||||
result
|
||||
end
|
||||
|
||||
|
||||
|
||||
private
|
||||
|
||||
class Tablerowloop < Liquid::Drop
|
||||
attr_accessor :length
|
||||
|
||||
def initialize(idx_i, idx_col, length)
|
||||
@idx_i, @idx_col, @length = idx_i, idx_col, length
|
||||
end
|
||||
|
||||
def index
|
||||
@context.registers[:tablerowloop][@idx_i] + 1
|
||||
end
|
||||
|
||||
def index0
|
||||
@context.registers[:tablerowloop][@idx_i]
|
||||
end
|
||||
|
||||
def rindex
|
||||
length - @context.registers[:tablerowloop][@idx_i]
|
||||
end
|
||||
|
||||
def rindex0
|
||||
length - @context.registers[:tablerowloop][@idx_i] - 1
|
||||
end
|
||||
|
||||
def first
|
||||
(@context.registers[:tablerowloop][@idx_i] == 0)
|
||||
end
|
||||
|
||||
def last
|
||||
(@context.registers[:tablerowloop][@idx_i] == length - 1)
|
||||
end
|
||||
|
||||
def col
|
||||
@context.registers[:tablerowloop][@idx_col] + 1
|
||||
end
|
||||
|
||||
def col0
|
||||
@context.registers[:tablerowloop][@idx_col]
|
||||
end
|
||||
|
||||
def col_first
|
||||
(@context.registers[:tablerowloop][@idx_col] == 0)
|
||||
end
|
||||
|
||||
def col_last
|
||||
(@context.registers[:tablerowloop][@idx_col] == cols - 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Template.register_tag('tablerow', TableRow)
|
||||
end
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user