Class: Amrita2View::Base
Constant Summary
collapse
- CompileTimeBinding =
binding
- @@compiled_amrita2_templates =
{}
- @@text_domain =
nil
Amrita2::Util::AMP_WITHOUT_REFRENCE, Amrita2::Util::DefaultAllowedScheme, Amrita2::Util::NAME, Amrita2::Util::NAMECHAR, Amrita2::Util::NOT_REFERENCE, Amrita2::Util::UrlInvalidChar
Constants included
from Amrita2
Amrita2::FilterMethods, Amrita2::Hooki, Amrita2::SanitizedString
Instance Method Summary
collapse
sanitize_attribute_value, sanitize_text, sanitize_url
#amrita_get_context_value, #amrita_set_context_value, #end_tag, #new_element, #start_tag
Constructor Details
#initialize(action_view) ⇒ Base
124
125
126
|
# File 'lib/amrita2/rails_bridge.rb', line 124
def initialize( action_view )
@action_view = action_view
end
|
Instance Method Details
#render(template, local_assigns = {}) ⇒ Object
128
129
130
131
132
133
134
135
|
# File 'lib/amrita2/rails_bridge.rb', line 128
def render(template, local_assigns={})
Thread::current[:amrita_rails_view] = @action_view
if template.kind_of?(String)
render_amrita(template, local_assigns)
else
@action_view.render(template, local_assigns)
end
end
|
#render_amrita(template, local_assigns) ⇒ Object
158
159
160
161
162
163
|
# File 'lib/amrita2/rails_bridge.rb', line 158
def render_amrita(template, local_assigns)
@@compiled_amrita2_templates[template] ||= setup_template(template)
tmpl = @@compiled_amrita2_templates[template]
b = setup_binding_of_view(local_assigns)
tmpl.render_with(b)
end
|
#setup_binding_of_view(local_assigns) ⇒ Object
165
166
167
168
169
170
171
172
173
174
175
|
# File 'lib/amrita2/rails_bridge.rb', line 165
def setup_binding_of_view(local_assigns)
@action_view.instance_eval do
evaluate_assigns
b = binding
local_assigns.each do |k, v|
amrita_set_context_value(v)
eval "#{k}=amrita_get_context_value",b
end
b
end
end
|
#setup_template(template) ⇒ Object
137
138
139
|
# File 'lib/amrita2/rails_bridge.rb', line 137
def setup_template(template)
setup_template_default(template)
end
|
#setup_template_default(template) ⇒ Object
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
# File 'lib/amrita2/rails_bridge.rb', line 141
def setup_template_default(template)
if Amrita2::const_defined?(:GetTextBridge)
t = Amrita2::Template.new(template) do |e, src, filters|
filters << Amrita2::Filters::GetTextFilter.new
end
t.text_domain = text_domain
bindtextdomain(t.text_domain)
t.compiletime_binding = CompileTimeBinding
t
else
t = Amrita2::Template.new(template)
t.compiletime_binding = CompileTimeBinding
t
end
end
|