This repository was archived by the owner on Jul 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path_helpers.rb
More file actions
87 lines (73 loc) · 2.43 KB
/
Copy path_helpers.rb
File metadata and controls
87 lines (73 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
class EmailTemplateHelpers < Middleman::Extension
def initialize(app, options_hash={}, &block)
super
@@app = app
app.set :contentAreaCounter, 0
end
helpers do
def getvar ns, var
return data.template[ns][var]
end
def content_area(area = "", parameters = {})
@@app.set :contentAreaCounter, contentAreaCounter + 1
if ( is_building == true )
concat '<custom type="content" name="contentarea' + contentAreaCounter.to_s + '">'
else
if ( add_regions && add_regions == true )
region(area) do
concat partial("content/" + area, { :locals => parameters })
end
else
concat partial("content/" + area, { :locals => parameters })
end
end
end
def empty_content_area
@@app.set :contentAreaCounter, contentAreaCounter + 1
if ( is_building == true )
concat '<custom type="content" name="contentarea' + contentAreaCounter.to_s + '">'
end
end
def page_data ns, var
return is_building == true ? "%%=v(@" + ns.to_s + "_" + var.to_s + ")=%%" : getvar(ns, var)
end
def page_link ns, var
return is_building == true ? "%%=redirectto(@" + ns.to_s + "_" + var.to_s + ")=%%" : getvar(ns, var)
end
def page_link_format ns, var
alias_var = var.to_s + "_alias"
if ( getvar(ns, alias_var).nil? || getvar(ns, alias_var).empty? )
raise "Variable " + ns.to_s + " => " + var.to_s + " needs an alias"
end
if ( is_building == true )
return "href=\"%%=redirectto(@" + ns.to_s + "_" + var.to_s + ")=%%\" alias=\"%%=redirectto(@" + ns.to_s + "_" + alias_var + ")=%%\""
else
return "href=\"" + getvar(ns, var) + "\" alias=\"" + getvar(ns, alias_var) + "\""
end
end
def image_src filename
return images_dir + "/" + filename
end
def region regionName, force=false
if ( is_building == true || force == true )
concat "%%=BeginImpressionRegion(\"" + regionName + "\")=%%"
yield
concat "%%=EndImpressionRegion()=%%"
else
yield
end
end
def if_page_data ns, var
if ( is_building == true )
concat "%%[if not empty(@" + ns.to_s + "_" + var.to_s + ") then]%%"
yield
concat "%%[endif]%%"
else
if ( getvar(ns, var) )
yield
end
end
end
end
end
::Middleman::Extensions.register(:email_template_helpers, EmailTemplateHelpers)