Class: Template
Constant Summary collapse
- @@fdelim =
'%='- @@placeholders =
{:dict_list => 'dict_list', :glossary => 'index'}
- @@def_template =
%~<?xml version="1.0" encoding="utf-8"?> <!-- created with HTML2Index #{VERSION}--> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="application/xhtml+xml" /> <meta name="revisit-after" content="30 days" /> <title>Glossaire</title> <style type="text/css"> body {font-family:LinuxBiolinum, Trebuchet;} h1 {margin-left:1em; margin-bottom:1em;} div.content {margin-bottom:9em;margin-left:2em;width:80%;border:1px solid #000060;padding:1em;border-radius:1em;} div.sources {border:0.5pt solid #000060;border-radius:1em;padding:0 0.5em 0 0.5em;background-color:#e0e0f0;margin:3em;width:40em;} dt {font-weight:bold;color:#000070;} div.navtop {border:1px solid #000000;border-radius:1em;background-color:#ffffff;font-weight:bold;font-size:1.3em;position:fixed;top:1em;right:7em;} a {text-decoration:none;} a:hover {border:1px solid #800000;border-radius:1em;} dd i {text-decoration:underline;} #omega {color:#a000a0;font-weight:bold;text-align:right;margin-right:12em;} </style> </head> <body> <div class="navtop" title="début"><a href="#top">⇧</a></div> <div><a id="top"></a></div> <p style="position:absolute;right:2em;top:2em;">généré avec html2index #{VERSION}, #{Date.today.to_s}</p> <h1>Glossaire </h1> <div class="sources"> <h2>Sources</h2> <!-- ============================ --> <!-- Insert list of dictionaries --> #{@@fdelim}#{@@placeholders[:dict_list]}#{@@fdelim.reverse} <!-- ============================ --> </div> <div class="content"> <!-- ============================ --> <!-- Insert glossary --> #{@@fdelim}#{@@placeholders[:glossary]}#{@@fdelim.reverse} <!-- ============================ --> <div id="omega">Ω</div> </div> </body> </html>~
Instance Attribute Summary collapse
-
#template ⇒ Object
Returns the value of attribute template.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Template
constructor
A new instance of Template.
- #to_s ⇒ Object
Methods included from BasicLogging
#clear_log, is_muted?, #level, #log, mute, #set_level, #set_target, #target
Constructor Details
#initialize ⇒ Template
Returns a new instance of Template.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/template.rb', line 26 def initialize() set_level = $log_level template_file = $configuration.template @template = nil if template_file error = nil [:file?, :readable?].each do |cond| if(!File.send(cond, template_file) ) error = true warn('Cannot use template ' << template_file << ': NOT ' << cond.to_s.split('?')[0] << ',' << "\n\tusing default template") end end if(!error) @template = File.read(template_file) debug('using template ' << template_file) end end end |
Instance Attribute Details
#template ⇒ Object
Returns the value of attribute template.
57 58 59 |
# File 'lib/template.rb', line 57 def template @template end |
Class Method Details
.default(name) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/template.rb', line 59 def self::default(name) case name when :fdelim @@fdelim when :placeholders @@placeholders when :def_template @@def_template else error('Do not know ' << name.to_s) error('Aborting. Bye!') end end |
Instance Method Details
#to_s ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/template.rb', line 46 def to_s str = nil if @template && @template.respond_to?(:to_str) str = @template else warn('Empty template, using default!') str = @@def_template end str end |