Class: Tonka::HTML
- Inherits:
-
Object
- Object
- Tonka::HTML
- Defined in:
- lib/tonka.rb
Instance Attribute Summary collapse
-
#layout ⇒ Object
CSS processing module.
Instance Method Summary collapse
- #add_css_files(options) ⇒ Object
- #add_handlebars_template(options) ⇒ Object
- #add_js_files(options) ⇒ Object
-
#initialize(options = []) ⇒ HTML
constructor
A new instance of HTML.
- #render(options) ⇒ Object
Constructor Details
#initialize(options = []) ⇒ HTML
Returns a new instance of HTML.
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/tonka.rb', line 125 def initialize(=[]) @layout_arrays = [] @layout_array_0 = ["<!DOCTYPE html>\n"] if .include?("-angular") @layout_array_1 = ["<html ng-app>\n"] else @layout_array_1 = ["<html>\n"] end @layout_array_2 = ["<head>\n","\t<title>#{$SITE_NAME}</title>\n"] @link_array = add_css_files() @script_array = add_js_files() @layout_array_3 = ["</head>\n","<body>\n"] @script_array_2 = () @layout_array_4 = ["</body>\n","</html>"] end |
Instance Attribute Details
#layout ⇒ Object
CSS processing module
123 124 125 |
# File 'lib/tonka.rb', line 123 def layout @layout end |
Instance Method Details
#add_css_files(options) ⇒ Object
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
# File 'lib/tonka.rb', line 180 def add_css_files() = [] .each do |option| library_name = option.gsub("-","") Tonka::CSS.libraries.each do |library| if library[library_name] css = Tonka::CSS.new(library_name) << (css.link_tag + "\n") end end end << (Tonka::CSS.new("style").link_tag + "\n") return end |
#add_handlebars_template(options) ⇒ Object
196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/tonka.rb', line 196 def () tag = [] = "\t<script id='template' type='text/x-handlebars-template'>\n \t</script>\n" .each do |option| library_name = option.gsub("-","") if library_name == "handlebars" tag << end end return tag end |
#add_js_files(options) ⇒ Object
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/tonka.rb', line 152 def add_js_files() = [] .each do |option| library_name = option.gsub("-","") if library_name == "backbone" && !.include?("jquery") jquery = Tonka::JS.new("jquery") << jquery.script_tag end if library_name == "backbone" && !.include?("underscore") underscore = Tonka::JS.new("underscore") << underscore.script_tag end if library_name == "bootstrap" && !.include?("jquery") jquery = Tonka::JS.new("jquery") << jquery.script_tag end Tonka::JS.libraries.each do |library| if library[library_name] js = Tonka::JS.new(library_name) << js.script_tag end end end << Tonka::JS.new("app").script_tag return end |
#render(options) ⇒ Object
141 142 143 144 145 146 147 148 149 150 |
# File 'lib/tonka.rb', line 141 def render() @index_html = File.new("#{$SITE_NAME}/index.html","w") @layout = @layout_array_0.join("") + @layout_array_1.join("") + @layout_array_2.join("") + @link_array.join("") + @script_array.join("") + @layout_array_3.join("") + @script_array_2.join("") + @layout_array_4.join("") @index_html.puts @layout @index_html.close puts "\t\tbuilt ".green+"#{$SITE_NAME}/index.html" end |