Class: Dyndoc::TemplateContentOnly

Inherits:
Object
  • Object
show all
Defined in:
lib/dyndoc/content_only.rb

Constant Summary collapse

@@cfg =
{
  :version=>:V3,
  :format_doc => :tex, #instead of :output
  :format_output => :tex, ## :tex or :html or :tm or :odt
  :mode_doc => :tex, #execution mode
  :rootDoc=>"",
  #:model_doc=>"default", #NO MODEL in this mode
  :pre_doc=>[],
  :post_doc=>[],
  :cmd=> [], # :save , :cat, :pdf or :png, :view behaving differently depending on the format_doc
  :cmd_pandoc_options => [],
  :enc => "utf8"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cfg = {}) ⇒ TemplateContentOnly

Returns a new instance of TemplateContentOnly.



22
23
24
25
26
27
# File 'lib/dyndoc/content_only.rb', line 22

def initialize(cfg={})
  @content=""
  @cfg=cfg
  @tmpl_cfg=@@cfg.dup
  @tmplMngr=Dyndoc.tmpl_mngr
end

Instance Attribute Details

#cfgObject

Returns the value of attribute cfg.



20
21
22
# File 'lib/dyndoc/content_only.rb', line 20

def cfg
  @cfg
end

#contentObject

Returns the value of attribute content.



20
21
22
# File 'lib/dyndoc/content_only.rb', line 20

def content
  @content
end

#tmpl_cfgObject

Returns the value of attribute tmpl_cfg.



20
21
22
# File 'lib/dyndoc/content_only.rb', line 20

def tmpl_cfg
  @tmpl_cfg
end

Instance Method Details

#init_tmplObject Also known as: init_doc



29
30
31
32
33
# File 'lib/dyndoc/content_only.rb', line 29

def init_tmpl
  @tmplMngr.init_doc(@tmpl_cfg)
  @tmplMngr.init_model(@content) #no model since @cfg[:model_doc] is nil! But, default libraries are loaded!    
  @tmplMngr.parse(File.read(Dyndoc.doc_filename("Dyn/Minimum"))+"\n",@tmplMngr.filterGlobal)
end

#make_content(content = nil) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/dyndoc/content_only.rb', line 48

def make_content(content=nil)
  @content=content if content
  ##@tmplMngr.cfg[:debug]=true
  if @tmplMngr.cfg[:debug]
    ##puts "@content";p @content
    return prepare_content
  else
    begin
      return prepare_content 
    # rescue
    #   print "WARNING: fail to eval content #{@content} !!\n"
    #   return ""
    end
  end
end

#prepare_contentObject



42
43
44
45
46
# File 'lib/dyndoc/content_only.rb', line 42

def prepare_content
  #Dyndoc.warn "prepare_content",@content
  out=@tmplMngr.parse(@content)
  return out
end

#require_dyndoc_libs(libs) ⇒ Object



37
38
39
40
# File 'lib/dyndoc/content_only.rb', line 37

def require_dyndoc_libs(libs)
  libs="{#require]\n"+libs.split("\n").map{|lib| lib.split(",")}.flatten.uniq.join("\n")+"\n[#}\n"
  @tmplMngr.parse(libs,@tmplMngr.filterGlobal)
end