Liking cljdoc? Tell your friends :D

tornado.compiler

The Tornado compiler, where you should only care about these 4 functions: css, repl-css, compile-expression, html-style.

The Tornado compiler, where you should only care about these 4 functions:
css, repl-css, compile-expression, html-style.
raw docstring

*at-media-indent*clj/s

Extra indentation when nested inside a media query.

Extra indentation when nested inside a media query.
sourceraw docstring

*flags*clj/s

The current flags for a tornado build compilation:

:indent-length - Specifies, how many indentation spaces should be in the compiled CSS file after any nesting in @rule or params map. Defaults to 4.

:pretty-print? - Specifies, whether the compiled CSS should be pretty printed. Defaults to true. If set to false, the CSS file will be compressed after compilation (removal of unnecessary characters like spaces and newlines) to make the CSS file a bit smaller.

:output-to - Specifies, where the compiled CSS file should be saved.

The current flags for a tornado build compilation:

:indent-length - Specifies, how many indentation spaces should be in the compiled
                 CSS file after any nesting in @rule or params map. Defaults to 4.

:pretty-print? - Specifies, whether the compiled CSS should be pretty printed.
                 Defaults to true. If set to false, the CSS file will be compressed
                 after compilation (removal of unnecessary characters like spaces
                 and newlines) to make the CSS file a bit smaller.

:output-to     - Specifies, where the compiled CSS file should be saved.
sourceraw docstring

*in-params-context*clj/s

source

*indent*clj/s

source

*keyframes-indent*clj/s

Extra indentation when nested inside keyframes.

Extra indentation when nested inside keyframes.
sourceraw docstring

*media-query-parents*clj/s

Current parents Used for compiling @media to temporarily store parents paths for compiling @media changes.

Current parents Used for compiling @media to temporarily store parents
paths for compiling @media changes.
sourceraw docstring

attr-map-to-cssclj/s

(attr-map-to-css attributes-map)

Compiles an attributes map and translates the compiled data to CSS: (attr-map-to-css {:width (units/percent 50) :margin [[0 (units/px 15) (units/css-rem 3) :auto]] :background-color (colors/rotate-hue "#ff0000" 60)}) => width: 50%; margin: 0 15px rem3 auto; background-color: hsl(60 1 0.5);

Compiles an attributes map and translates the compiled data to CSS:
(attr-map-to-css {:width            (units/percent 50)
                  :margin           [[0 (units/px 15) (units/css-rem 3) :auto]]
                  :background-color (colors/rotate-hue "#ff0000" 60)})
=> width: 50%;
   margin: 0 15px rem3 auto;
   background-color: hsl(60 1 0.5);
sourceraw docstring

calc-keywordsclj/s

A special map for calc keywords.

A special map for calc keywords.
sourceraw docstring

comma-joinclj/s

(comma-join {:keys [compiles-to args]})

Redefining functions/comma-join because there would be a cyclic dependency otherwise.

Redefining functions/comma-join because there would be a cyclic dependency otherwise.
sourceraw docstring

compile-all-selectors-params-combinationsclj/s

(compile-all-selectors-params-combinations prepared-hiccup)

Given a prepared hiccup vector (with precalculated and simplified combinations of all selectors, children and params), this function generates a CSS string from the data.

Given a prepared hiccup vector (with precalculated and simplified combinations of all
selectors, children and params), this function generates a CSS string from the data.
sourceraw docstring

compile-at-ruleclj/smultimethod

Generates CSS from a CSSAtRule record, at the moment, these are available: at-media, at-keyframes, at-font-face.

E.g.: #tornado.types.CSSAtRule{:identifier "media" :value {:rules {:min-width "500px" :max-width "700px"} :changes [:.abc {:margin-top "20px"}]}}

Depending on the :identifier ("media" in this case), a relevant method is called.

Generates CSS from a CSSAtRule record, at the moment, these are available:
at-media, at-keyframes, at-font-face.

E.g.:
#tornado.types.CSSAtRule{:identifier "media"
                         :value      {:rules   {:min-width "500px"
                                                 :max-width "700px"}
                                      :changes [:.abc {:margin-top "20px"}]}}

Depending on the :identifier ("media" in this case), a relevant method is called.
sourceraw docstring

compile-attributes-mapclj/s

(compile-attributes-map attributes-map)

Compiles an attributes map, returns a sequence of [compiled-attribute compiled-value].

Compiles an attributes map, returns a sequence of [compiled-attribute compiled-value].
sourceraw docstring

compile-colorclj/smultimethod

Generates CSS from a color, calls a relevant method to do so depending on the color's type: "rgb", "rgba", "hsl", "hsla", keyword, string, keyword (for keywords, tries to get an exact hex-value of the color from colors/default-colors), otherwise prints out a warning and returns a string form of that keyword.

Generates CSS from a color, calls a relevant method to do so depending on the
color's type:
"rgb", "rgba", "hsl", "hsla", keyword, string, keyword (for keywords,
tries to get an exact hex-value of the color from colors/default-colors),
otherwise prints out a warning and returns a string form of that keyword.
sourceraw docstring

compile-css-recordclj/smultimethod

Compiles a CSS record (unit, function, at-rule, color). For 4 different types of CSS selectors, there is a different multifunction "compile-selector".

Compiles a CSS record (unit, function, at-rule, color). For 4 different types of
CSS selectors, there is a different multifunction "compile-selector".
sourceraw docstring

compile-expressionclj/s

(compile-expression expr)

Compiles an expression: a number, string, symbol or a record. If the expression is a vector of sequential structures, compiles each of the structures and str/joins them with a space. Then, str/joins all these str/space-joined structures with a comma.

E.g.: (compile-expression [[(u/px 15) (u/percent 20)] [:red :chocolate]]) => "15px 20%, #FF0000 #D2691E"

Compiles an expression: a number, string, symbol or a record. If the expression is
a vector of sequential structures, compiles each of the structures and str/joins them
with a space. Then, str/joins all these str/space-joined structures with a comma.

E.g.:
(compile-expression [[(u/px 15) (u/percent 20)] [:red :chocolate]])
=> "15px 20%, #FF0000 #D2691E"
sourceraw docstring

compile-paramsclj/s

(compile-params attributes-map)

Given a map of HTML style attributes described in Tornado, compiles all the values of the parameters, but the parameters names remain the same. This function is useful for Reagent to allow you describing the style with Tornado. Example usage:

(compile-params {:width (px 500) :background-color (important (rgb 100 150 200)) :border [[(px 1) :solid :black]] :display :flex})

=> {:width "500px", :background-color "rgb(100, 150, 200) !important", :border "1px solid #000000", :display "flex"}

Given a map of HTML style attributes described in Tornado, compiles all the values
of the parameters, but the parameters names remain the same. This function is useful
for Reagent to allow you describing the style with Tornado.
Example usage:

(compile-params {:width            (px 500)
                 :background-color (important (rgb 100 150 200))
                 :border           [[(px 1) :solid :black]]
                 :display          :flex})

=> {:width            "500px",
    :background-color "rgb(100, 150, 200) !important",
    :border           "1px solid #000000",
    :display          "flex"}
sourceraw docstring

compile-selectorclj/smultimethod

Compiles a CSS combinator, attribute selector, pseudoclass or pseudoelement or a selector in a keyword/symbol/string form.

Compiles a CSS combinator, attribute selector, pseudoclass or pseudoelement
or a selector in a keyword/symbol/string form.
sourceraw docstring

compile-selectorsclj/s

(compile-selectors selectors-sequences)

Given a sequence of selectors paths, e.g. '([:iframe :.abc] [:#def sel/after :.ghi]), this function translates all the selectors paths to CSS and str/joins them with a comma, which is a shorthand that can be used in CSS to give different selectors paths the same parameters. ... => "iframe .abc, #def::after .ghi"

Given a sequence of selectors paths, e.g. '([:iframe :.abc] [:#def sel/after :.ghi]),
this function translates all the selectors paths to CSS and str/joins them with a comma,
which is a shorthand that can be used in CSS to give different selectors paths the same
parameters. ... => "iframe .abc, #def::after .ghi"
sourceraw docstring

compile-selectors-and-paramsclj/s

(compile-selectors-and-params {:keys [paths params at-media at-font-face
                                      at-keyframes]})

For a current :paths & :params/:at-media map, translates the paths (selectors) which all have the equal params map or at-media record to CSS and str/joins them with a comma (a shorthand which can be used in CSS). Also translates the params map or at-media record to CSS and creates a CSS block from these compiled things, e.g.: (compile-selectors-and-params {:paths #{[:.abc :#def :iframe] [:td :span sel/hover]} :params {:color :font-black :margin [[(units/px 15) (units/em 2)]] :display :flex}} => .abc #def iframe, td span:hover { color: #1A1B1F; margin: 15px 2em; display: flex; }

For a current :paths & :params/:at-media map, translates the paths (selectors) which
all have the equal params map or at-media record to CSS and str/joins them with a comma
(a shorthand which can be used in CSS). Also translates the params map or at-media
record to CSS and creates a CSS block from these compiled things, e.g.:
(compile-selectors-and-params {:paths  #{[:.abc :#def :iframe] [:td :span sel/hover]}
                               :params {:color   :font-black
                                        :margin  [[(units/px 15) (units/em 2)]]
                                        :display :flex}}
=> .abc #def iframe, td span:hover {
       color: #1A1B1F;
       margin: 15px 2em;
       display: flex;
    }
sourceraw docstring

compile-selectors-sequenceclj/s

(compile-selectors-sequence selectors-path)

Given a path of selectors, which can contain special selectors, this function generates a CSS string from the selectors.

Given a path of selectors, which can contain special selectors, this function
generates a CSS string from the selectors.
sourceraw docstring

conjsclj/s

(conjs s value)

Conj(oin)s to a (potentially empty) set.

Conj(oin)s to a (potentially empty) set.
sourceraw docstring

cssclj/s

(css css-hiccup)
(css flags css-hiccup)

Generates CSS from a standard Tornado vector (or a list of hiccup vectors). If pretty-print? is set to false, compresses it as well. Then saves the compiled CSS to a given file path, if provided in the flags.

You can also call this function only with the hiccup vector, without any flags.

Generates CSS from a standard Tornado vector (or a list of hiccup vectors). If
pretty-print? is set to false, compresses it as well. Then saves the compiled CSS
to a given file path, if provided in the flags.

You can also call this function only with the hiccup vector, without any flags.
sourceraw docstring

CSS-AtRuleclj/s

source

CSS-Attributeclj/s

source

CSS-Colorclj/s

source

CSS-Combinatorclj/s

source

CSS-Functionclj/s

source

CSS-PseudoClassclj/s

source

CSS-PseudoClassFnclj/s

source

CSS-PseudoElementclj/s

source

CSS-Unitclj/s

source

expand-hiccup-list-for-compilationclj/s

(expand-hiccup-list-for-compilation parents
                                    unevaluated-hiccup
                                    nested-hiccup-vectors-list)

Given a hiccup element path (parents) and current unevaluated hiccup, this function first expands all lists and lazy sequences until it comes across a structure which is neither of them. After that, the function recursively goes through all hiccup vectors in the expanded hiccup vectors list: The current vector of unevaluated hiccup combinations is passed to another expanding function which recursively calculates all combinations of a current hiccup vector by calling itself and then this function for deeper expanding again - all combinations of its selectors (+ selectors received from parents), params and children. It then inserts all these combinations to the unevaluated hiccup and returns it updated with the combinations inserted.

Given a hiccup element path (parents) and current unevaluated hiccup, this function
first expands all lists and lazy sequences until it comes across a structure which
is neither of them. After that, the function recursively goes through all hiccup vectors
in the expanded hiccup vectors list:
The current vector of unevaluated hiccup combinations is passed to another expanding
function which recursively calculates all combinations of a current hiccup vector by
calling itself and then this function for deeper expanding again - all combinations of
its selectors (+ selectors received from parents), params and children. It then
inserts all these combinations to the unevaluated hiccup and returns it updated with
the combinations inserted.
sourceraw docstring

expand-hiccup-vectorclj/s

(expand-hiccup-vector parents unevaluated-hiccup hiccup-vector)

Given a (potentially nil) current parents sequence, unevaluated hiccup combinations in a vector the current hiccup vector, which is in a form [sel1 maybe-sel2 maybe-sel3 ... {maybe-params-map} [maybe-child1] [maybe-child2] ... ] where each child is a hiccup vector as well, this function adds all combinations of selectors and descendant children and their selectors together with corresponding parameters (or skips the combination of params are nil) to the unevaluated-hiccup argument, recursively.

Given a (potentially nil) current parents sequence, unevaluated hiccup combinations
in a vector the current hiccup vector, which is in a form
[sel1 maybe-sel2 maybe-sel3 ... {maybe-params-map} [maybe-child1] [maybe-child2] ... ]
where each child is a hiccup vector as well, this function adds all combinations
of selectors and descendant children and their selectors together with corresponding
parameters (or skips the combination of params are nil) to the unevaluated-hiccup
argument, recursively.
sourceraw docstring

flatten-seqsclj/s

(flatten-seqs coll)

Recursively expands collections for which (seq? coll) returns true. Always expands the first collection, even if it is e.g. a vector ((seq? []) is false); all more deeply nested collections will not be expanded. See clojure.core/flatten.

Recursively expands collections for which `(seq? coll)` returns true. Always expands
the first collection, even if it is e.g. a vector ((seq? []) is false); all more
deeply nested collections will not be expanded.
See clojure.core/flatten.
sourceraw docstring

html-styleclj/s

(html-style attributes-map)

Can be used for compilation of a map of style parameters to a single string of html style="..." attribute. Receives the styles map as its argument and returns a string of compiled style:

(html-style {:width (px 500) :height (percent 15) :color :font-black :background-color :teal})

=> "width:500px;height:15%;color:#1A1B1F;background-color:#008080"

Can be used for compilation of a map of style parameters to a single string of html
style="..." attribute. Receives the styles map as its argument and returns a string
of compiled style:

(html-style {:width            (px 500)
             :height           (percent 15)
             :color            :font-black
             :background-color :teal})

=> "width:500px;height:15%;color:#1A1B1F;background-color:#008080"
sourceraw docstring

just-cssclj/s

(just-css css-hiccup)

Compiles the hiccup to a string of CSS. Does not do any printing or file output, that is what the functions below are. This one is separate to simplify both functions css and repl-css which just do something with the output of this function.

Compiles the hiccup to a string of CSS. Does not do any printing or file output,
that is what the functions below are. This one is separate to simplify both
functions css and repl-css which just do something with the output of this function.
sourceraw docstring

repl-cssclj/s

(repl-css css-hiccup)

Generates CSS from a standard Tornado hiccup vector (or a list of hiccup vectors) and pretty prints the output CSS string, which is useful for evaluating any tornado code in the REPL.

Generates CSS from a standard Tornado hiccup vector (or a list of hiccup vectors)
and pretty prints the output CSS string, which is useful for evaluating any tornado
code in the REPL.
sourceraw docstring

selectors-params-childrenclj/s

(selectors-params-children hiccup)

Given a hiccup vector, this function returns a map with keys :selectors, :params, :children and :at-media, where each of these keys' value is a vector of those elements. Besides :params, which is returned as a map, since there cannot be more than 1 params map. Including incorrect elements or failing to comply the right order of the elements [selector &more-selectors? params? &<children? at-media?*>] will throw a detailed error message.

Given a hiccup vector, this function returns a map with keys :selectors, :params,
:children and :at-media, where each of these keys' value is a vector of those
elements. Besides :params, which is returned as a map, since there cannot be more
than 1 params map.
Including incorrect elements or failing to comply the right order of the elements
[selector &more-selectors? params? &<children? at-media?*>]
will throw a detailed error message.
sourceraw docstring

simplify-prepared-expanded-hiccupclj/s

(simplify-prepared-expanded-hiccup path-params-vector)

Simplifies the expanded hiccup vector: A new map will be created for every unique parameters map or at-media record with {:params {...}, :paths #{...}} (with :at-media instead of :params alternatively), where elements with equal params or at-media record will be inserted to a set behind the :paths key. This function returns a vector of these unique params/at-media maps.

Simplifies the expanded hiccup vector: A new map will be created for every unique
parameters map or at-media record with {:params {...}, :paths #{...}} (with :at-media
instead of :params alternatively), where elements with equal params or at-media record
will be inserted to a set behind the :paths key. This function returns a vector of
these unique params/at-media maps.
sourceraw docstring

special-media-rules-mapclj/s

A special map for generating media queries rules, e.g.: (tornado.at-rules/at-media {:rules {:screen :only -> "only screen" :screen false -> "not screen" :screen true -> "screen"} ... })

A special map for generating media queries rules, e.g.:
(tornado.at-rules/at-media {:rules {:screen  :only   -> "only screen"
                                    :screen  false   -> "not screen"
                                    :screen  true    -> "screen"} ... })
sourceraw docstring

update-in-keysclj/s

(update-in-keys m f path & ks)

Given a map or a record, a function, a common partial path and keys which will be appended to that path, updates all keys in the given map with that function.

Given a map or a record, a function, a common partial path and keys which will be
appended to that path, updates all keys in the given map with that function.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close