Browse Source

refactor: replace custom helpers

feature/migrate-to-haml-js
Yoshiya Hinosawa 7 years ago
parent
commit
e12ac635db
  1. 26
      config.rb
  2. 6
      docs/_sample.haml
  3. 2
      docs/layouts/layout.haml

26
config.rb

@ -1,29 +1,5 @@
helpers do
def js_as_plain(id)
f = open("docs/js/samples/" + id + ".js")
js = f.read
f.close
js
end
def data_as_plain(name)
f = open("docs/data/" + name)
data = f.read
f.close
data
end
def css_as_plain(name)
f = open("docs/css/samples/" + name)
css = f.read
f.close
css
end
def get_css_name(path)
path.gsub('.html', '')
end
end
set :source, 'docs' set :source, 'docs'
set :haml, { :ugly => true, :format => :html5 } set :haml, { :format => :html5 }
set :css_dir, 'css' set :css_dir, 'css'
set :js_dir, 'js' set :js_dir, 'js'
set :images_dir, 'img' set :images_dir, 'img'

6
docs/_sample.haml

@ -10,14 +10,14 @@
.sourcecode.margin-medium-v.margin-small-h .sourcecode.margin-medium-v.margin-small-h
%h3 # #{id}.js %h3 # #{id}.js
#javascript-editor.c3-editor #javascript-editor.c3-editor
= js_as_plain id = File.read "docs/js/samples/#{id}"
- if defined? other_css - if defined? other_css
.sourcecode .sourcecode
%h3 # #{other_css} %h3 # #{other_css}
%pre %pre
%code.css %code.css
= css_as_plain other_css = File.read "docs/css/samples/#{other_css}"
- if defined? other_files - if defined? other_files
- other_files.each do |f| - other_files.each do |f|
@ -25,7 +25,7 @@
%h3 # #{f} %h3 # #{f}
%pre %pre
%code.html %code.html
= data_as_plain f = File.read "docs/data/#{f}"
= partial :footer = partial :footer

2
docs/layouts/layout.haml

@ -16,7 +16,7 @@
= stylesheet_link_tag 'tomorrow' = stylesheet_link_tag 'tomorrow'
= stylesheet_link_tag 'c3' = stylesheet_link_tag 'c3'
= stylesheet_link_tag 'style' = stylesheet_link_tag 'style'
= stylesheet_link_tag get_css_name(current_page.path) = stylesheet_link_tag current_page.path.gsub('.html', '')
:javascript :javascript
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){

Loading…
Cancel
Save