Sha256: 05d0951bb526d5df5ea60fea2de89ee6041f24ed2fe4d188d3ae5c03d6763b3a
Contents?: true
Size: 1.07 KB
Versions: 7
Compression:
Stored size: 1.07 KB
Contents
module Babylon module Base ## # Your application's views (stanzas) should be descendant of this class. class View attr_reader :output, :view_template ## # Instantiate a new view with the various varibales passed in assigns and the path of the template to render. def initialize(path, assigns) @output = "" @view_template = path assigns.each do |key, value| instance_variable_set("@#{key}", value) self.class.send(:define_method, key) do # Defining accessors value end end end ## # "Loads" the view file, and uses the Nokogiri Builder to build the XML stanzas that will be sent. def evaluate str = (Babylon.cached_views && Babylon.cached_views[@view_template]) ? Babylon.cached_views[@view_template] : File.read(@view_template) xml = Nokogiri::XML::Builder.new do instance_eval(str) end return xml.doc.children #we return the doc's children (to avoid the instruct) end end end end
Version data entries
7 entries across 7 versions & 1 rubygems