noprompt/lein-garden


Leiningen plugin for compiling Garden stylesheets.

License: Unlicense

Language: Clojure


lein-garden

A Leiningen plugin for automatically compiling Garden stylesheets.

Help!

This project is looking for team members! Please open an issue if you would like to support this project by joining the team.

Requirements

This plugin requires Clojure version 1.6.0 or higher and Leiningen version 2.5.0 or higher.

Installation

Add the following dependency to the :plugins vector of your project.clj.

Clojars Project

How do I use this?

Preface

Let's suppose you have a project where you are currently using Garden for CSS generation. Now, imagine you're so tired of manually recompiling your stylesheets or resorting to some other form of skulduggery that you're thinking of going back to Sass. This causes you to reflect deeply on your life for a moment before realizing that it's just negativity talking and get back to hacking.

Chapter 1

You open ~/cash-money/src/cash_money/core.clj.

(ns cash-money.core
  (:require [garden.def :refer [defstylesheet defstyles]]
            [garden.units :refer [px]]))

(defstylesheet screen
  {:output-to "resources/public/screen.css"}
  [:body
   {:font-family "sans-serif"
    :font-size (px 16)
    :line-height 1.5}])

There's a namespace to the north and a some Garden code to the south.

You think to yourself, "this is nice if you're the sort of person that doesn't mind constantly reloading the file to recompile the CSS after every save." Alas, you are not one of these "persons." Instead, you've added [lein-garden "X.X.X"] to your :plugins vector, read "Getting Things Done", and like Landon Austin are ready for anything.

Chapter 2

You open ~/cash-money/project.clj

(defproject cash-money "1.1.1"
  :plugins [[lein-garden "X.X.X"]])

To get everything going with lein garden you add the remaining ingredients.

(defproject cash-money "1.1.1"
  :plugins [[lein-garden "X.X.X"]]
  :garden {:builds [{;; Optional name of the build:
                     :id "screen"
                     ;; Source paths where the stylesheet source code is
                     :source-paths ["src/styles"]
                     ;; The var containing your stylesheet:
                     :stylesheet cash-money.core/screen
                     ;; Compiler flags passed to `garden.core/css`:
                     :compiler {;; Where to save the file:
                                :output-to "resources/screen.css"
                                ;; Compress the output?
                                :pretty-print? false}}]})

Next, you open ~/cash-money/src/styles/cash_money/core.clj and make a small change.

(ns cash-money.core
  (:require [garden.def :refer [defstylesheet defstyles]]
            [garden.units :refer [px]]))

;; Change defstylesheet to defstyles.
(defstyles screen
  [:body
   {:font-family "sans-serif"
    :font-size (px 16)
    :line-height 1.5}])

Finally you run

$ lein garden auto

and behold as your stylesheet is automatically recompiled on save.

Chapter 3

Now you might want stylesheets to always compile whenever starting your program with leiningen. Add this to your project.clj

:prep-tasks [["garden" "once"]]

Chapter 4

To remove css on lein clean, you should add the compiled files to :clean-targets in your project.clj

Project Statistics

Sourcerank 6
Repository Size 60.5 KB
Stars 75
Forks 14
Watchers 6
Open issues 9
Dependencies 3
Contributors 14
Tags 18
Created
Last updated
Last pushed

Top Contributors See all

Joel Holdbrooks Robin Heggelund Hansen Martin Klepsch Pedro Antonio Souza Viegas Peter Jaros Sean Doig Juho Teperi Johannes Goslar FungusHumungus Conner Petzold Wei Tang Keith Irwin Dave Liepmann Priyatam Mudi

Packages Referencing this Repo

lein-garden
A Leiningen plugin for automatically compiling Garden stylesheets
Latest release 0.3.0 - Updated - 75 stars

Recent Tags See all

v0.2.8 May 19, 2016
v0.2.7 March 10, 2016
v0.2.5 October 30, 2014
v0.2.4 October 23, 2014
v0.2.3 October 23, 2014
v0.2.2 October 13, 2014
v0.2.1 September 09, 2014
v0.2.0 August 16, 2014
v0.1.9 July 24, 2014
v0.1.8 March 03, 2014
v0.1.7 March 02, 2014
v0.1.6 February 24, 2014
v0.1.5 January 27, 2014
v0.1.4 January 26, 2014
v0.1.3 January 26, 2014

Something wrong with this page? Make a suggestion

Last synced: 2016-09-14 14:53:23 UTC

Login to resync this repository