Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to repeat Middleman build process with different variables?

We're using Middleman with HAML.

The site we're building should support multiple themes, and themes' markup differs from from one theme to another and we're using some variables to configure each theme.

I'm looking for a way to have Middleman to repeat the build for each theme I need with its variable values.

like image 778
IgalSt Avatar asked Nov 20 '25 10:11

IgalSt


1 Answers

I would recommend using a variable within config.rb, e.g.:

set :theme, ENV['THEME'] || 'red'

That way you can access it within your templates using settings.theme:

%p Current theme is #{content_tag(:strong, settings.theme)}.

Which should prompt: "Current theme is red."


Now the fun part, invoking ...

# on a linux/unix shell    
THEME='blue' middleman build
# on a windows shell
set THEME=red & middleman build

... or ...

# on a linux/unix shell    
THEME='yellow' middleman build
# on a windows shell
set THEME=yellow & middleman build

... via the shell sets ENV['THEME'] e.g. your theme name and should bring you the different themed builds.

like image 87
Volker Rose Avatar answered Nov 24 '25 03:11

Volker Rose