Class: Dot_Why::Template
- Inherits:
-
Erector::Widget
- Object
- Erector::Widget
- Dot_Why::Template
show all
- Includes:
- Cosmo, Diet_Dot, Ok
- Defined in:
- lib/Ok.rb,
lib/Cosmo.rb,
lib/dot_why.rb,
lib/Diet_Dot.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Diet_Dot
#dot, #dot_array, #dot_i, #dot_tertiary, #dot_v, #inline_rawdot, #rawdot, #var
Methods included from Cosmo
#inline_var, #var, #var_block
Methods included from Ok
#add_mtime, #applet, #as_this_life_menu, #on_off, #script, #span_as
Constructor Details
#initialize(raw_file, *args) ⇒ Template
Returns a new instance of Template.
9
10
11
12
13
14
|
# File 'lib/dot_why.rb', line 9
def initialize raw_file, *args
file = File.expand_path(raw_file).sub(".rb", "") + '.rb'
@_blocks = {}
super(*args)
eval(File.read("#{file}"), nil, file, 1)
end
|
Class Method Details
.blocks(*args) ⇒ Object
17
18
19
20
21
22
23
|
# File 'lib/dot_why.rb', line 17
def blocks *args
args.each do |word|
define_method(word.to_sym) do |pos = :bottom, &b|
block word, pos, &b
end
end
end
|
Instance Method Details
#block(raw_name, pos = :bottom, *args, &b) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/dot_why.rb', line 28
def block raw_name, pos = :bottom, *args, &b
name = raw_name.to_sym
if (b)
@_blocks[name] ||= []
if (pos == :top)
@_blocks[name].unshift(b)
elsif (pos == :replace)
@_blocks[name] = [b]
else
@_blocks[name].push(b)
end
else
(@_blocks[name] || []).each do |bl|
bl.call
end
end
end
|
#content ⇒ Object
60
61
62
|
# File 'lib/dot_why.rb', line 60
def content
main
end
|
#link(*args) ⇒ Object
52
53
54
55
56
57
58
|
# File 'lib/dot_why.rb', line 52
def link *args
if (@_link_type == :css && args.length == 1 && args[0].instance_of?(String))
super(:rel=>"stylesheet", :type=>"text/css", :href=>args[0])
else
super
end
end
|
#styles(*args, &b) ⇒ Object
46
47
48
49
50
|
# File 'lib/dot_why.rb', line 46
def styles *args, &b
@_link_type = :css
block :styles, *args, &b
@_link_type = nil
end
|