Top Level Namespace
Defined Under Namespace
Classes: Datagnan
Instance Method Summary collapse
-
#datagnan(template_file, options = {}, local_vars = {}) ⇒ Object
Helper function (for Sinatra, primarily).
-
#oga ⇒ Object
Oga for HTML parsing (Yeah, no Nokogiri!).
Instance Method Details
#datagnan(template_file, options = {}, local_vars = {}) ⇒ Object
Helper function (for Sinatra, primarily)
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
# File 'lib/datagnan.rb', line 345 def datagnan(template_file, = {}, local_vars = {}) # beginning_time = Time.now ## default options [:scope] ||= self [:views_dir] = File.realpath([:views_dir] || ([:scope].settings.views if [:scope].settings) || "./views") [:layout_file] = File.join([:views_dir], [:layout_file] || 'layout.html') ([:local_vars] ||= {}).merge! local_vars ## prepare template filename template_file = File.join([:views_dir], template_file.to_s) template_file += '.html' unless File.exist? template_file ## render template html = Datagnan.read(template_file, ) ## debug # puts "-- datagnan ( template = #{html} )" ## check for layout and wrap template if exist if File.exist? [:layout_file] [:local_vars]['template'] = { 'html' => html } html = Datagnan.read([:layout_file], ) ## debug # puts "-- datagnan ( layout = #{html} )" end # end_time = Time.now # puts "Time elapsed for datagnan #{(end_time - beginning_time)*1000} milliseconds" return html end |
#oga ⇒ Object
Oga for HTML parsing (Yeah, no Nokogiri!)
2 |
# File 'lib/datagnan.rb', line 2 require 'oga' |