OSDN Git Service

Regular updates
[twpd/master.git] / middleman.md
1 ---
2 title: Middleman 3
3 category: JavaScript libraries
4 ---
5
6 **NB:** This is for Middleman 3, not Middleman 4+.
7
8 ### Compass config
9
10     compass_config do |config|
11       config.output_style = :compact
12     end
13
14 ### Config
15
16     # Automatic image dimensions on image_tag helper
17     activate :automatic_image_sizes
18
19 ### Gems
20
21     # Susy grids in Compass
22     # First: gem install compass-susy-plugin
23     require 'susy'
24
25     # CodeRay syntax highlighting in Haml
26     # First: gem install haml-coderay
27     require 'haml-coderay'
28
29     # CoffeeScript filters in Haml
30     # First: gem install coffee-filter
31     require 'coffee-filter'
32
33
34 ### Page command
35
36     # With no layout
37     page "/path/to/file.html", :layout => false
38
39     # With alternative layout
40     page "/path/to/file.html", :layout => :otherlayout
41
42     # A path which all have the same layout
43     with_layout :admin do
44       page "/admin/*"
45     end
46
47     # Proxy (fake) files
48     page "/this-page-has-no-template.html", :proxy => "/template-file.html" do
49       @which_fake_page = "Rendering a fake page with a variable"
50     end
51
52 ### Helpers
53
54     helpers do
55       def some_helper
56         "Helping"
57       end
58     end
59
60 ### Directories
61
62     set :css_dir, "alternative_css_directory"
63     set :js_dir, "alternative_js_directory"
64     set :images_dir, "alternative_image_directory"
65
66 # Build-specific configuration
67
68     configure :build do
69       activate :minify_css
70       activate :minify_javascript
71
72       # Enable cache buster
73       activate :cache_buster
74
75       # Use relative URLs
76       activate :relative_assets
77
78       # Compress PNGs after build
79       # First: gem install middleman-smusher
80       # require "middleman-smusher"
81       activate :smusher
82
83       # Or use a different image path
84       set :http_path, "/Content/images/"
85     end