Class: Tilt::DynDocTemplate

Inherits:
Template
  • Object
show all
Defined in:
lib/dyndoc/common/tilt.rb

Direct Known Subclasses

DynHtmlTemplate, DynTtmTemplate, DynTxtlTemplate

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.engine_initialized?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/dyndoc/common/tilt.rb', line 65

def self.engine_initialized?
  defined? ::DynDoc
end

.init(libs = nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dyndoc/common/tilt.rb', line 10

def DynDocTemplate.init(libs=nil)
  # unless $curDyn
  #   require 'dyndoc/V3/init/dyn'
  #   CqlsDoc.init_dyn
  #   CqlsDoc.set_curDyn(:V3)
  #   $curDyn.init(false)
  #   $curDyn.tmpl_doc.init_doc
  #   if libs
  #     @@libs=libs
  #     $curDyn.tmpl_doc.require_dyndoc_libs(libs)
  #   end
  #   "options(bitmapType='cairo')".to_R
  #   $curDyn.tmpl.format_output="html"
  #   $curDyn.tmpl.dyndoc_mode=:web # No command line
  #   #p [$curDyn.tmpl.dyndocMode,$curDyn.tmpl.fmtOutput]
  # end

  ## same as interactive-server
  @tmpl_mngr=nil
  @tmpl_filename=nil
  init_dyndoc
end

Instance Method Details

#evaluate(scope, locals, &block) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/dyndoc/common/tilt.rb', line 80

def evaluate(scope, locals, &block)

#=begin
  #puts "locals";p locals
  ## first!!!!
  if locals.keys.include? :init_doc and locals[:init_doc]
      $curDyn.tmpl_doc.init_doc
      $curDyn.tmpl_doc.require_dyndoc_libs(@@libs) if @@libs
      "options(bitmapType='cairo')".to_R
      $curDyn.tmpl.format_output="html"
      $curDyn.tmpl.dyndoc_mode=:web # No command line
    #p [$curDyn.tmpl.dyndocMode,$curDyn.tmpl.fmtOutput]
      locals.delete :init_doc
  end
	locals.each do |tag, value|
      if tag==:path
        CqlsDoc.setRootDoc($curDyn[:rootDoc],value)
      elsif tag==:libs
        @@libs=libs
      else
    	 $curDyn.tmpl.filterGlobal.envir[tag]=value
      end
  end
#=end
  $curDyn.tmpl.filterGlobal.envir["yield"]=block.call if block
	@output=prepare_output
	#puts @output
	#@output
end

#init_dyndocObject



33
34
35
36
37
38
39
40
# File 'lib/dyndoc/common/tilt.rb', line 33

def init_dyndoc
  unless @tmpl_mngr
    Dyndoc.cfg_dyn['dyndoc_session']=:interactive
    @tmpl_mngr = Dyndoc::Ruby::TemplateManager.new({})
    ##is it really well-suited for interactive mode???
  end
  reinit_dyndoc
end

#initialize_engineObject



69
70
71
# File 'lib/dyndoc/common/tilt.rb', line 69

def initialize_engine
	DynDocTemplate.init
end

#prepareObject



73
# File 'lib/dyndoc/common/tilt.rb', line 73

def prepare; end

#prepare_outputObject



76
77
78
# File 'lib/dyndoc/common/tilt.rb', line 76

def prepare_output
return process_dyndoc(data)
end

#process_dyndoc(content) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/dyndoc/common/tilt.rb', line 51

def process_dyndoc(content)
  ##p [:process_dyndoc_content,content]
  @content=@tmpl_mngr.parse(content)
  ##Dyndoc.warn :content, @content
  @tmpl_mngr.filterGlobal.envir["body.content"]=@content
  if @tmpl_filename
    @tmpl_mngr.filterGlobal.envir["_FILENAME_CURRENT_"]=@tmpl_filename.dup
    @tmpl_mngr.filterGlobal.envir["_FILENAME_"]=@tmpl_filename.dup #register name of template!!!
    @tmpl_mngr.filterGlobal.envir["_FILENAME_ORIG_"]=@tmpl_filename.dup #register name of template!!!
    @tmpl_mngr.filterGlobal.envir["_PWD_"]=File.dirname(@tmpl_filename)
  end
  return @content
end

#reinit_dyndocObject



42
43
44
45
46
47
48
49
# File 'lib/dyndoc/common/tilt.rb', line 42

def reinit_dyndoc
  if @tmpl_mngr
    @tmpl_mngr.init_doc({:format_output=> "html"})
    @tmpl_mngr.require_dyndoc_libs("DyndocWebTools")
    puts "InteractiveServer (re)initialized!\n"
    @tmpl_mngr.as_default_tmpl_mngr! #=> Dyndoc.tmpl_mngr activated!
  end
end