sliq 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/LICENSE +21 -0
- data/README.md +29 -0
- data/lib/sliq.rb +91 -0
- data/lib/sliq/version.rb +3 -0
- data/sliq.gemspec +23 -0
- metadata +79 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1f01903d83883e33082443c0e560f64334c0f2ef
|
4
|
+
data.tar.gz: 924d87a4037f20f0708f857428888f32c608d43b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 448495ca60361231e704c29204fcfef184a4c744d25dc32482ba72dfcfa0e1f43bd71aa9280938db7b45aebbfcfeafbec86ffa7afefcc2cc678688283d35203c
|
7
|
+
data.tar.gz: 823a5ced7fb24a137835fceac146c7121e98242368737db9c27409b4bb9fcd6ad7f74bdfd6f0d2c8d9f4d386c06fcb050346604f2c155f9100e43deded92d033
|
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2014 Slim Team
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Sliq
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/sliq.png)](http://rubygems.org/gems/sliq) [![Build Status](https://secure.travis-ci.org/slim-template/sliq.png?branch=master)](http://travis-ci.org/slim-template/sliq) [![Dependency Status](https://gemnasium.com/slim-template/sliq.png?travis)](https://gemnasium.com/slim-template/sliq) [![Code Climate](https://codeclimate.com/github/slim-template/sliq.png)](https://codeclimate.com/github/slim-template/sliq) [![Gittip donate button](http://img.shields.io/gittip/bevry.png)](https://www.gittip.com/min4d/ "Donate weekly to this project using Gittip")
|
4
|
+
[![Flattr donate button](https://raw.github.com/balupton/flattr-buttons/master/badge-89x18.gif)](https://flattr.com/submit/auto?user_id=min4d&url=http%3A%2F%2Fsliq-lang.org%2F "Donate monthly to this project using Flattr")
|
5
|
+
|
6
|
+
Sliq integrates [Slim](http://slim-lang.com) with [Liquid](http://liquidmarkup.org/). This is pretty much experimental.
|
7
|
+
|
8
|
+
## Links
|
9
|
+
|
10
|
+
* Source: <http://github.com/slim-template/slim>
|
11
|
+
* Bugs: <http://github.com/slim-template/sliq/issues>
|
12
|
+
* List: <http://groups.google.com/group/slim-template>
|
13
|
+
* API documentation:
|
14
|
+
* Latest Gem: <http://rubydoc.info/gems/sliq/frames>
|
15
|
+
* GitHub master: <http://rubydoc.info/github/slim-template/sliq/master/frames>
|
16
|
+
|
17
|
+
## Try it yourself
|
18
|
+
|
19
|
+
You currently have to use the Tilt template class manually.
|
20
|
+
|
21
|
+
Syntax example:
|
22
|
+
|
23
|
+
~~~
|
24
|
+
% for product in products
|
25
|
+
li
|
26
|
+
h2 {{product.title}}
|
27
|
+
| Only {{ product.price | format_as_money }}
|
28
|
+
p {{ product.description | prettyprint | truncate: 200 }}
|
29
|
+
~~~
|
data/lib/sliq.rb
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'slim'
|
2
|
+
require 'sliq/version'
|
3
|
+
require 'tilt/liquid'
|
4
|
+
|
5
|
+
module Sliq
|
6
|
+
class Parser < Slim::Parser
|
7
|
+
set_default_options :attr_list_delims => {
|
8
|
+
'(' => ')',
|
9
|
+
'[' => ']'
|
10
|
+
}
|
11
|
+
|
12
|
+
def unknown_line_indicator
|
13
|
+
case @line
|
14
|
+
when /\A%\s*(\w+)/
|
15
|
+
@line = $'
|
16
|
+
parse_liquid_tag($1)
|
17
|
+
when /\A\{/
|
18
|
+
block = [:multi]
|
19
|
+
@stacks.last << [:multi, [:slim, :interpolate, @line], block]
|
20
|
+
@stacks << block
|
21
|
+
else
|
22
|
+
super
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def parse_liquid_tag(name)
|
27
|
+
block = [:multi]
|
28
|
+
@stacks.last << [:liquid, :tag, name, @line.strip, block]
|
29
|
+
@stacks << block
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class Tags < Slim::Filter
|
34
|
+
def on_liquid_tag(name, args, block)
|
35
|
+
if empty_exp?(block)
|
36
|
+
[:static, "{% #{name} #{args} %}"]
|
37
|
+
else
|
38
|
+
[:multi,
|
39
|
+
[:static, "{% #{name} #{args} %}\n"],
|
40
|
+
block,
|
41
|
+
[:static, "\n{% end#{name} %}"]]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class Interpolation < Slim::Interpolation
|
47
|
+
def on_slim_attrvalue(escape, code)
|
48
|
+
if code =~ /\A\{\{.*\}\}\Z/
|
49
|
+
[:static, code]
|
50
|
+
else
|
51
|
+
[:slim, :attrvalue, escape, code]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def on_slim_interpolate(string)
|
56
|
+
block = [:multi]
|
57
|
+
begin
|
58
|
+
case string
|
59
|
+
when /\A\{/
|
60
|
+
string, code = parse_expression($')
|
61
|
+
block << [:escape, false, [:slim, :interpolate, "{#{code}}"]]
|
62
|
+
when /\A([^\{]*)/
|
63
|
+
block << [:slim, :interpolate, $&]
|
64
|
+
string = $'
|
65
|
+
end
|
66
|
+
end until string.empty?
|
67
|
+
block
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
class Engine < Slim::Engine
|
72
|
+
replace Slim::Parser, Parser, :file, :tabsize, :shortcut, :default_tag, :attr_delims, :attr_list_delims, :code_attr_delims
|
73
|
+
before Slim::Interpolation, Interpolation
|
74
|
+
after Parser, Tags
|
75
|
+
end
|
76
|
+
|
77
|
+
Converter = Temple::Templates::Tilt(Engine)
|
78
|
+
|
79
|
+
class Template < Tilt::Template
|
80
|
+
def prepare
|
81
|
+
@converter = Converter.new(options) { data }
|
82
|
+
end
|
83
|
+
|
84
|
+
def evaluate(scope, locals, &block)
|
85
|
+
liquid = @converter.render(scope, locals, &block)
|
86
|
+
Tilt::LiquidTemplate.new(options) { liquid }.render(scope, locals, &block)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
Tilt.register(Sliq::Template, 'sliq')
|
data/lib/sliq/version.rb
ADDED
data/sliq.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.dirname(__FILE__) + '/lib/sliq/version'
|
3
|
+
require 'date'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'sliq'
|
7
|
+
s.version = Sliq::VERSION
|
8
|
+
s.date = Date.today.to_s
|
9
|
+
s.authors = ['Daniel Mendler']
|
10
|
+
s.email = ['mail@daniel-mendler.de']
|
11
|
+
s.summary = 'Slim and Liquid working together.'
|
12
|
+
s.description = 'Process template with Slim and Liquid afterwards.'
|
13
|
+
s.homepage = 'http://slim-lang.com/'
|
14
|
+
s.rubyforge_project = s.name
|
15
|
+
s.license = 'MIT'
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = %w(lib)
|
20
|
+
|
21
|
+
s.add_runtime_dependency('slim', ['~> 2.0.3']) # TODO: Require > 2.0.3 later!
|
22
|
+
s.add_runtime_dependency('liquid', ['~> 2.5.5'])
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sliq
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Mendler
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: slim
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.0.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.0.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: liquid
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.5.5
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.5.5
|
41
|
+
description: Process template with Slim and Liquid afterwards.
|
42
|
+
email:
|
43
|
+
- mail@daniel-mendler.de
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- LICENSE
|
50
|
+
- README.md
|
51
|
+
- lib/sliq.rb
|
52
|
+
- lib/sliq/version.rb
|
53
|
+
- sliq.gemspec
|
54
|
+
homepage: http://slim-lang.com/
|
55
|
+
licenses:
|
56
|
+
- MIT
|
57
|
+
metadata: {}
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
require_paths:
|
61
|
+
- lib
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
requirements: []
|
73
|
+
rubyforge_project: sliq
|
74
|
+
rubygems_version: 2.2.2
|
75
|
+
signing_key:
|
76
|
+
specification_version: 4
|
77
|
+
summary: Slim and Liquid working together.
|
78
|
+
test_files: []
|
79
|
+
has_rdoc:
|