Module: XX::Expandable::InstanceMethods

Defined in:
lib/xx.rb,
lib/xx-2.1.0.rb

Overview

–{{{

Instance Method Summary collapse

Instance Method Details

#xx_expand(template, opts = {}) ⇒ Object

–}}}


773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
# File 'lib/xx.rb', line 773

def xx_expand template, opts = {}#--{{{

  port = opts['port'] || opts[:port] || STDOUT
  pretty = opts['pretty'] || opts[:pretty]
  binding = opts['binding'] || opts[:binding]

  type = template.type

  unless type === self 
    klass = self.class
    klass.module_eval{ include type } 
  end

  display = pretty ? 'pretty' : 'to_str'

  Binding.of_caller do |scope|
    binding ||= eval('binding', scope)
    doc = eval template.template, binding 
    doc.send display, port
  end#--}}}

end

#xx_expand_file(*a, &b) ⇒ Object Also known as: xx_expand_path, xx_expand_template

–}}}


795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
# File 'lib/xx.rb', line 795

def xx_expand_file *a, &b #--{{{

  template = xx_template_file *a, &b 

  type = template.type
  pretty = template.pretty
  port = template.port

  unless type === self 
    klass = self.class
    klass.module_eval{ include type } 
  end

  display = pretty ? 'pretty' : 'to_str'

  Binding.of_caller do |scope|
    binding ||= eval('binding', scope)
    doc = eval template.template, binding 
    doc.send display, port
  end#--}}}

end

#xx_expand_inline(*a, &b) ⇒ Object Also known as: xx_expand_string


819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
# File 'lib/xx.rb', line 819

def xx_expand_inline *a, &b #--{{{

  template = xx_template_inline *a, &b 

  type = template.type
  pretty = template.pretty
  port = template.port

  unless type === self 
    klass = self.class
    klass.module_eval{ include type } 
  end

  display = pretty ? 'pretty' : 'to_str'

  Binding.of_caller do |scope|
    binding ||= eval('binding', scope)
    doc = eval template.template, binding 
    doc.send display, port
  end#--}}}

end

#xx_template_file(*a, &b) ⇒ Object

–{{{


759
760
761
762
763
764
765
# File 'lib/xx.rb', line 759

def xx_template_file *a, &b#--{{{

  template = XX::Template::File.new *a, &b
  template.object ||= self
  template#--}}}

end

#xx_template_inline(*a, &b) ⇒ Object

–}}}


766
767
768
769
770
771
772
# File 'lib/xx.rb', line 766

def xx_template_inline *a, &b#--{{{

  template = XX::Template::Inline.new *a, &b
  template.object ||= self
  template#--}}}

end