tzispa_rig 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +182 -2
- data/lib/tzispa/rig/template.rb +2 -3
- data/lib/tzispa/rig/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 484c207b444e399e36b3b280ec31d19bde762aaf
|
4
|
+
data.tar.gz: d72e7fc08e477694bde0eb6d38ca6c415796fb8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3d55a81e78788feb9c3eedd9a287ca467ec45024c244049a2e5d0553e47de5c9a6cd50a41ebc6cbbd991075d48256ee943e24e7e0764e45c76cbbe3fe91cd17
|
7
|
+
data.tar.gz: f132ca420011439890b476f274bf145a6331da7b10a4ac63f89128dfe68132e2c7074195c3a9bdbf2e3a2cbca722275475205615175bcdc99e6fc920fd173115
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,183 @@
|
|
1
|
-
|
1
|
+
# Tzispa Rig
|
2
2
|
|
3
|
-
|
3
|
+
A general purpose template engine
|
4
|
+
|
5
|
+
## Rig template types
|
6
|
+
|
7
|
+
There are 3 template types: layout, static and block:
|
8
|
+
|
9
|
+
* layout: these are the skeleton entry points of the rig templates
|
10
|
+
* static: these are "light" templates that are a included without any processing as plain text
|
11
|
+
* block: the true core of the rig templates, each block template file has an associated ruby file with the template binder class
|
12
|
+
|
13
|
+
To add templates to your app you can use cli coomands
|
14
|
+
|
15
|
+
```shell
|
16
|
+
% tzispa generate rig lister --type=layout --app=mainapp
|
17
|
+
% tzispa generate rig sitefoot --type=static --app=mainapp
|
18
|
+
% tzispa generate rig product_detail --type=block --app=mainapp
|
19
|
+
```
|
20
|
+
|
21
|
+
## Rig template language
|
22
|
+
|
23
|
+
### Variables and metavariables
|
24
|
+
|
25
|
+
Template variables are specified with:
|
26
|
+
```
|
27
|
+
<var:name/>
|
28
|
+
```
|
29
|
+
|
30
|
+
And metavariables with:
|
31
|
+
```
|
32
|
+
{%name%}
|
33
|
+
```
|
34
|
+
metavariables are used to make runtime template tags replacements
|
35
|
+
|
36
|
+
```html
|
37
|
+
<fieldset>
|
38
|
+
<div class='row'>
|
39
|
+
<div class='column column-80'>
|
40
|
+
<label for='name'>Nombre *</label>
|
41
|
+
<input type='text' name='name' id='name' maxlength="64" value='<var:name/>' required='required' />
|
42
|
+
</div>
|
43
|
+
<div class='column column-20'>
|
44
|
+
<label for='skey'>Código</label>
|
45
|
+
<input type='text' name='skey' id='skey' maxlength="16" value='{%skey%}'/>
|
46
|
+
</div>
|
47
|
+
</div>
|
48
|
+
....
|
49
|
+
|
50
|
+
```
|
51
|
+
|
52
|
+
and in the template binder
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
def bind!
|
56
|
+
@idb = context.router_params[:id0]
|
57
|
+
load_brand if idb
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
attr_reader :idb
|
63
|
+
|
64
|
+
def load_brand
|
65
|
+
context.repository.use :ecomm_shop
|
66
|
+
brand = context.repository[:brand][idb]
|
67
|
+
data(
|
68
|
+
idb: brand.id,
|
69
|
+
name: brand.name,
|
70
|
+
skey: brand.skey,
|
71
|
+
long_name: brand.long_name,
|
72
|
+
web: brand.web,
|
73
|
+
manual_order: brand.manual_order,
|
74
|
+
notes: brand.notes
|
75
|
+
)
|
76
|
+
end
|
77
|
+
```
|
78
|
+
|
79
|
+
### Conditionals
|
80
|
+
|
81
|
+
You can make decisions in your templates using conditionals:
|
82
|
+
|
83
|
+
```html
|
84
|
+
<ife:customer_exist>
|
85
|
+
<div class='row'>
|
86
|
+
<div class='column column-80'>
|
87
|
+
<label for='name'>Nombre *</label>
|
88
|
+
<input type='text' name='name' id='name' maxlength="64" value='<var:name/>' required='required' />
|
89
|
+
</div>
|
90
|
+
<div class='column column-20'>
|
91
|
+
<label for='skey'>Código</label>
|
92
|
+
<input type='text' name='skey' id='skey' maxlength="16" value='{%skey%}'/>
|
93
|
+
</div>
|
94
|
+
</div>
|
95
|
+
<else:customer_exist/>
|
96
|
+
<p> There isn't any customer here </p>
|
97
|
+
</ife:customer_exist>
|
98
|
+
```
|
99
|
+
|
100
|
+
In the binder you must define customer_exist
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
def bind!
|
104
|
+
idc = context.router_params[:id0]
|
105
|
+
context.repository.use :ecomm_shop
|
106
|
+
customer = context.repository[:customer][idb]
|
107
|
+
data.customer_exist = !customer.nil?
|
108
|
+
end
|
109
|
+
```
|
110
|
+
|
111
|
+
## Repeating
|
112
|
+
|
113
|
+
To repeat a part in the template
|
114
|
+
|
115
|
+
```html
|
116
|
+
<loop:lbrands>
|
117
|
+
<tr>
|
118
|
+
<td><var:id/></td>
|
119
|
+
<td><var:skey/></td>
|
120
|
+
<td><var:name/></td>
|
121
|
+
<td class='text-right'>
|
122
|
+
<a href='<purl:site[layout=brand_edit,title=edit-brand,id0={%id%}]/>'><i class='fa fa-edit'></i></a>
|
123
|
+
<a href='javascript:delete_brand("<api:brand:delete:{%id%}/>")'><i class='fa fa-trash'></i></a>
|
124
|
+
</td>
|
125
|
+
<tr>
|
126
|
+
</loop:lbrands>
|
127
|
+
```
|
128
|
+
|
129
|
+
In the binder you must use the 'loop_binder' method
|
130
|
+
|
131
|
+
```ruby
|
132
|
+
|
133
|
+
def bind!
|
134
|
+
data.lbrands = loop_binder(:lbrands).bind!(&load_brands)
|
135
|
+
end
|
136
|
+
|
137
|
+
private
|
138
|
+
|
139
|
+
def load_brands
|
140
|
+
Proc.new {
|
141
|
+
context.repository.use :ecomm_shop
|
142
|
+
context.repository[:brand].list.map { |b|
|
143
|
+
loop_item(
|
144
|
+
id: b.id,
|
145
|
+
skey: b.skey,
|
146
|
+
name: b.name
|
147
|
+
)
|
148
|
+
}
|
149
|
+
}
|
150
|
+
end
|
151
|
+
```
|
152
|
+
|
153
|
+
## Building urls
|
154
|
+
|
155
|
+
Rig templates can build urls for you. There are 2 url types:
|
156
|
+
|
157
|
+
### purl
|
158
|
+
|
159
|
+
Site urls: used to provide links to site pages
|
160
|
+
|
161
|
+
```
|
162
|
+
<purl:route_id/>
|
163
|
+
<purl:route_id[param1=value,param2=value]/>
|
164
|
+
```
|
165
|
+
```html
|
166
|
+
<purl:site[layout=brands,title=brand-list]/>
|
167
|
+
<purl:index/>
|
168
|
+
```
|
169
|
+
The route_id's area defined in the start.ru file
|
170
|
+
|
171
|
+
### api
|
172
|
+
|
173
|
+
Api urls: used to provide urls to the application Api
|
174
|
+
|
175
|
+
```
|
176
|
+
<api:handler:verb/>
|
177
|
+
<api:handler:verb:predicate/>
|
178
|
+
```
|
179
|
+
```html
|
180
|
+
<api:customer:add:address/>
|
181
|
+
|
182
|
+
<api:brand:{%verb%}/>
|
183
|
+
```
|
data/lib/tzispa/rig/template.rb
CHANGED
@@ -104,10 +104,9 @@ module Tzispa
|
|
104
104
|
"#{@domain.path}/rig/#{@type.to_s.downcase}#{'/'+@subdomain if @subdomain}"
|
105
105
|
end
|
106
106
|
|
107
|
-
def create
|
107
|
+
def create(content='')
|
108
108
|
FileUtils.mkdir_p(path) unless Dir.exist? path
|
109
|
-
|
110
|
-
super
|
109
|
+
super(content)
|
111
110
|
create_binder
|
112
111
|
end
|
113
112
|
|
data/lib/tzispa/rig/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tzispa_rig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Antonio Piñero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tzispa_helpers
|