Comparing version 0.0.8 to 0.0.9
@@ -1,9 +0,11 @@ | ||
Coco | ||
==== | ||
# Coco | ||
Coco is a fork of CoffeeScript that tries to eliminate some pain points. It has a very similar compiler to that of CoffeeScript, with even fewer options. The options are not documented anywhere explicitly, but I found just two being used in the source, documented below: | ||
Coco is a fork of coffeescript that tries to eliminate some pain points. It has a very similar compiler to that of coffeescript, with even fewer options. The options are not documented anywhere explicitly, but I found just two being used in the source, documented below: | ||
## Additional Options | ||
- filename: used for error reporting, built in to `compileFile` in accord | ||
- bare: compile without function closure | ||
### Bare | ||
- key: `bare` | ||
- type: `Boolean` | ||
- default: `false` | ||
These options are passed as an object as usual. | ||
Compile without function closure. |
@@ -1,13 +0,28 @@ | ||
CoffeeScript | ||
============ | ||
# CoffeeScript | ||
The CoffeeScript adapter API is almost exactly the same as the CoffeeScript JS API, making this an easy transition. The CoffeeScript JS API options are notoriously difficult to find anywhere online, so I've taken the liberty of listing out all the ones I could find here for you. | ||
The coffeescript adapter api is almost exactly the same as the coffeescript js api, making this an easy transition. The coffeescript js api options are notiriously difficult to find anywhere online, so I've taken the liberty of listing out all the ones I could find here for you. | ||
## Additional Options | ||
- `bare`: compile without function closure | ||
- `header`: inject a comment with the coffeescript version into all compiled files | ||
- `sourceMap`: generate a sourcemap on compile. requires `filename` | ||
- `filename`: for better error traces, highly recommended | ||
### Bare | ||
- key: `bare` | ||
- type: `Boolean` | ||
- default: `false` | ||
### Other Options I Don't Understand | ||
Compile without function closure | ||
### Header | ||
- key: `header` | ||
- type: `` | ||
- default: `` | ||
Inject a comment with the CoffeeScript version into all compiled files | ||
### SourceMap | ||
- key: `sourceMap` | ||
- type: `` | ||
- default: `` | ||
Generate a sourcemap on compile. requires `filename` | ||
## Other Options I Don't Understand | ||
While browsing the source, I cam across a few other options I didn't really get, and they are not documented anywhere. If anyone knows what these are, please contribute an explanation! | ||
@@ -14,0 +29,0 @@ |
@@ -1,4 +0,11 @@ | ||
CSSO | ||
==== | ||
# CSSO | ||
CSSO is a great tool for optimizing CSS. It's public API is very simple, sometimes to a fault, where it becomes difficult to track down errors. Although we're considering building in some extra error tracking in the future, for now just be careful. | ||
Csso is a great tool for optimizing css. It's public API is very simple, sometimes to a fault, where it becomes difficult to track down errors. Although we're considering building in some extra error tracking in the future, for now just be careful. The adapter only takes one option, `no_restructure`, which if set to true disables structure minimization (which means that if any selector appears twice, they are merged together)/ | ||
## Additional Options | ||
### No Restructure | ||
- key: `no_restructure` | ||
- type: `Boolean` | ||
- default: `false` | ||
If set to true it disables structure minimization. Structure minimization is a feature that merges together blocks that have the same selector. |
@@ -1,6 +0,4 @@ | ||
Dogescript | ||
========== | ||
# Dogescript | ||
Dogescript is potentially the greatest language on the internet. Not that this has anything to do with these docs, just couldn't resist adding it. It has a very simple and straightforward compiler that only takes two options, documented [here](https://github.com/remixz/dogescript#javascript) - only difference is that accord takes these via an options object rather than direct parameters, as usual. | ||
Dogescript is potentially the greatest language on the internet. Not that this has anyhting to do with these docs, just couldn't resist adding it. It has a very simple and straightforward compiler that only takes two options, documented [here](https://github.com/remixz/dogescript#javascript) - only difference is that accord takes these via an options object rather than direct parameters, as usual. | ||
Full options in an example: | ||
@@ -7,0 +5,0 @@ |
@@ -1,6 +0,4 @@ | ||
EJS | ||
=== | ||
# EJS | ||
EJS's interface, like Jade's, is almost the exact same as accord's. It simply takes an object of options. You can see those options [here](https://github.com/visionmedia/ejs#options). | ||
Ejs's interface, like jade's, is almost the exact same as accord's. It simply takes an object of options. You can see those options [here](https://github.com/visionmedia/ejs#options). | ||
Ejs supports client-side compiles as well. `compileClient` and `compileFileClient` method are both supported and return stringified anonymous functions. Ejs requires a few helpers in order to correctly render client-side templates, which can be attained by running `clientHelpers`, which also returns a string of minfied javascript. | ||
EJS supports client-side compiles as well. `compileClient` and `compileFileClient` method are both supported and return stringified anonymous functions. EJS requires a few helpers in order to correctly render client-side templates, which can be attained by running `clientHelpers`, which also returns a string of minfied javascript. |
@@ -1,9 +0,14 @@ | ||
HAML | ||
==== | ||
# HAML | ||
The haml compiler is very simple and fairly weak in comparison to other JavaScript templating engines (like Jade). It does not support any sort of layout system or includes, and it does not support client-side templates (yet). Its compile options are not documented, but here's what I could find in the source: | ||
The haml compiler is very simply and fairly weak in comparison to other similar javascript templating engines like jade. It does not support any sort of layout system or includes, and it does not support client-side templates (yet). It's compile options are not documented, but here's what I could find in the source: | ||
## Additional Options | ||
- `filename`: standard fare, used for reporting errors | ||
- `cache`: boolean, used to cache templates. filename required to use this, default false | ||
### Cache | ||
- key: `no_restructure` | ||
- type: `Boolean` | ||
- default: `false` | ||
Haml also allows you to [extend it](https://github.com/visionmedia/haml.js#extending-haml) with custom filters and doctypes, although this functionality has not yet been added to the accord adapter due to low demand. If there is a need, open an issue and/or pull request and adding it should not be too much work. | ||
Used to cache templates; `filename` is required to use this. | ||
## Extending HAML | ||
HAML also allows you to [extend it](https://github.com/visionmedia/haml.js#extending-haml) with custom filters and doctypes, although this functionality has not yet been added to the accord adapter due to low demand. If there is a need, open an issue and/or pull request and adding it should not be too much work. |
@@ -1,4 +0,2 @@ | ||
Handlebars | ||
========== | ||
# Handlebars | ||
Handlebars has an interesting way of operating, and a very obtuse API for its compiler. There aren't really any compiler options, but you can [register helpers](https://github.com/wycats/handlebars.js/#block-helpers) or [partials](https://github.com/wycats/handlebars.js/#partials) on the compiler itself before rendering, or [override the public api](https://github.com/wycats/handlebars.js/blob/7f6ef1dd38794f12aee33c76c04f604a7651810b/lib/handlebars/compiler/javascript-compiler.js#L10) (which is not currently allowed as a aprt of accord's wrapper). | ||
@@ -18,2 +16,2 @@ | ||
The handlebars adapter also supports client-side precompiled templates, meaning you can run `compileClient` and/or `compileFileClient` to get back a strinigifed anonymous function, `clientHelpers` returns a string of javascript helpers that must be included in any file that contains handlebars client-side templates in order for them to render correctly. | ||
The handlebars adapter also supports client-side precompiled templates, meaning you can run `compileClient` and/or `compileFileClient` to get back a strinigifed anonymous function, `clientHelpers` returns a string of JavaScript helpers that must be included in any file that contains handlebars client-side templates in order for them to render correctly. |
@@ -1,6 +0,4 @@ | ||
Jade | ||
==== | ||
# Jade | ||
The jade adapter is used in just about the exact same as the jade public api, making this adapter a very easy transition. Jade takes the [options listed here under "options"](http://jade-lang.com/api/) and they are fed through directly. | ||
Jade does support client-side templates, meaning `compileClient` and `compileFileClient` both work, returning stringified anonymous functions, and `clientHelpers` returns a string of javascript that must be in place in order for client-side templates to render properly. |
@@ -1,6 +0,4 @@ | ||
Less | ||
==== | ||
# LESS | ||
LESS has a very simple public API with just a couple options, which [can be found here](https://github.com/less/less.js/#configuration). The accord adapter takes all the same options other than the minify option, which is redundant as it can be provided through [minify-css](minify-css.md). Filename is automatically filled in when using `renderFile`, so no need to provide it. Full example below: | ||
Less has a very simple public API with just a couple options, which [can be found here](https://github.com/less/less.js/#configuration). The accord adapter takes all the same options other than the minify option, which is redundant as it can be provided through [minify-css](minify-css.md). Filename is automatically filled in when using `renderFile`, so no need to provide it. Full example below: | ||
```js | ||
@@ -7,0 +5,0 @@ less = accord.load('less'); |
@@ -1,8 +0,19 @@ | ||
LiveScript | ||
========== | ||
# LiveScript | ||
LiveScript is a fork of Coco, which is a fork of CoffeeScript. More info on changes and additons can be found [here](http://livescript.net/). | ||
LiveScript is a fork of coco, which is a fork of coffeescript. More info on changes and additons can be found [here](http://livescript.net/). It's compiler is unsurprisingly very similar to both coffeescript and coco, and has only three options, explained below: | ||
## Additional Options | ||
Its compiler is unsurprisingly very similar to both CoffeeScript and Coco, and has only 2 unique options, explained below. | ||
- filename: used for error reporting, built in to `renderFile` in accord | ||
- bare: compile without function wrapper | ||
- const: compile all variables as constants | ||
### Bare | ||
- key: `bare` | ||
- type: `Boolean` | ||
- default: `false` | ||
Compile without function closure. | ||
### Const | ||
- key: `const` | ||
- type: `Boolean` | ||
- default: `false` | ||
Compile all variables as constants |
@@ -1,4 +0,180 @@ | ||
Markdown | ||
======== | ||
# Markdown | ||
The markdown interface is very similar to the one [marked uses](https://github.com/chjj/marked#usage). | ||
The markdown interface is very similar to the one [marked uses](https://github.com/chjj/marked#usage), options can be found at the previous link and match 1:1 with the accord interface. | ||
## Additional Options | ||
### GFM | ||
- key: `gfm` | ||
- type: `Boolean` | ||
- default: `true` | ||
Enable GitHub Flavored Markdown. | ||
### Tables | ||
- key: `tables` | ||
- type: `Boolean` | ||
- default: `true` | ||
Enable GFM tables. This option requires the `gfm` option to be true. | ||
### Breaks | ||
- key: `breaks` | ||
- type: `Boolean` | ||
- default: `false` | ||
Enable GFM line breaks. This option requires the `gfm` option to be true. | ||
### Pedantic | ||
- key: `pedantic` | ||
- type: `Boolean` | ||
- default: `false` | ||
Conform to obscure parts of `markdown.pl` as much as possible. Don't fix any of the original markdown bugs or poor behavior. | ||
### Sanitize | ||
- key: `sanitize` | ||
- type: `Boolean` | ||
- default: `false` | ||
Sanitize the output. Ignore any HTML that has been inputted. | ||
### Smart Lists | ||
- key: `smartLists` | ||
- type: `Boolean` | ||
- default: `true` | ||
Use smarter list behavior than the original markdown. May eventually be | ||
default with the old behavior moved into `pedantic`. | ||
### Smart Typography | ||
- key: `smartypants` | ||
- type: `Boolean` | ||
- default: `false` | ||
Use "smart" typographic punctuation for things like quotes and dashes. | ||
### Highlight | ||
- key: `highlight` | ||
- type: `Function` | ||
A function to highlight code blocks. The first example below uses async highlighting with | ||
[node-pygmentize-bundled][pygmentize], and the second is a synchronous example using | ||
[highlight.js][highlight]: | ||
```js | ||
var marked = require('marked'); | ||
var markdownString = '```js\n console.log("hello"); \n```'; | ||
// Async highlighting with pygmentize-bundled | ||
marked.setOptions({ | ||
highlight: function (code, lang, callback) { | ||
require('pygmentize-bundled')({ lang: lang, format: 'html' }, code, function (err, result) { | ||
callback(err, result.toString()); | ||
}); | ||
} | ||
}); | ||
// Using async version of marked | ||
marked(markdownString, function (err, content) { | ||
if (err) throw err; | ||
console.log(content); | ||
}); | ||
// Synchronous highlighting with highlight.js | ||
marked.setOptions({ | ||
highlight: function (code) { | ||
return require('highlight.js').highlightAuto(code).value; | ||
} | ||
}); | ||
console.log(marked(markdownString)); | ||
``` | ||
#### Arguments | ||
##### Code | ||
- type: `String` | ||
The section of code to pass to the highlighter. | ||
##### Language | ||
- type: `String` | ||
The programming language specified in the code block. | ||
##### Callback | ||
- type: `Function` | ||
The callback function to call when using an async highlighter. | ||
### Renderer | ||
- key: `renderer` | ||
- type: `Object` | ||
- default: `new Renderer()` | ||
An object containing functions to render tokens to HTML. | ||
#### Overriding Renderer Methods | ||
The renderer option allows you to render tokens in a custom manor. Here is an | ||
example of overriding the default heading token rendering by adding an embedded anchor tag like on GitHub: | ||
```javascript | ||
var marked = require('marked'); | ||
var renderer = new marked.Renderer(); | ||
renderer.heading = function (text, level) { | ||
var escapedText = text.toLowerCase().replace(/[^\w]+/g, '-'); | ||
return '<h' + level + '><a name="' + | ||
escapedText + | ||
'" class="anchor" href="#' + | ||
escapedText + | ||
'"><span class="header-link"></span></a>' + | ||
text + '</h' + level + '>'; | ||
}, | ||
console.log(marked('# heading+', { renderer: renderer })); | ||
``` | ||
This code will output the following HTML: | ||
```html | ||
<h1> | ||
<a name="heading-" class="anchor" href="#heading-"> | ||
<span class="header-link"></span> | ||
</a> | ||
heading+ | ||
</h1> | ||
``` | ||
#### Block Level Renderer Methods | ||
- code(*string* code, *string* language) | ||
- blockquote(*string* quote) | ||
- html(*string* html) | ||
- heading(*string* text, *number* level) | ||
- hr() | ||
- list(*string* body, *boolean* ordered) | ||
- listitem(*string* text) | ||
- paragraph(*string* text) | ||
- table(*string* header, *string* body) | ||
- tablerow(*string* content) | ||
- tablecell(*string* content, *object* flags) | ||
`flags` has the following properties: | ||
```js | ||
{ | ||
header: true || false, | ||
align: 'center' || 'left' || 'right' | ||
} | ||
``` | ||
#### Inline Level Renderer Methods | ||
- strong(*string* text) | ||
- em(*string* text) | ||
- codespan(*string* code) | ||
- br() | ||
- del(*string* text) | ||
- link(*string* href, *string* title, *string* text) | ||
- image(*string* href, *string* title, *string* text) |
@@ -1,4 +0,2 @@ | ||
Minify CSS | ||
========== | ||
# Minify CSS | ||
CSS is minified with the fantastic [clean-css](https://github.com/GoalSmashers/clean-css) library. The direct compiler takes a hash of options just like accord does. You can see the [options that can be passed here](https://github.com/GoalSmashers/clean-css#how-to-use-clean-css-programmatically). |
@@ -1,4 +0,19 @@ | ||
Minify HTML | ||
=========== | ||
# Minify HTML | ||
The html minifier uses [html-minifier](https://github.com/kangax/html-minifier), which accepts a hash of options, a familiar interface. All options with explanations of what they do can be [found here](http://perfectionkills.com/experimenting-with-html-minifier/#options). | ||
The html minifier uses [html-minifier](https://github.com/kangax/html-minifier), which accepts a hash of options, a familiar interface. All options with explanations of what they do can be [found here](http://perfectionkills.com/experimenting-with-html-minifier/#options). If not otherwise specified, html will be minified with the following options set to true as defaults: `removeComments`, `collapseWhitespace`, and `removeEmptyAttributes`. | ||
## Additional Options | ||
# Remove Comments | ||
- key: `removeComments` | ||
- type: `Boolean` | ||
- default: `true` | ||
# Collapse Whitespace | ||
- key: `collapseWhitespace` | ||
- type: `Boolean` | ||
- default: `true` | ||
# Remove Empty Attributes | ||
- key: `removeEmptyAttributes` | ||
- type: `Boolean` | ||
- default: `true` |
@@ -1,4 +0,2 @@ | ||
Minify JS | ||
========= | ||
# Minify JS | ||
Uses [uglifyjs2](https://github.com/mishoo/UglifyJS2) to minify javascript code. The interface matches that of uglifyjs2, you can see some options that can be passed in [listed out here](https://github.com/mishoo/UglifyJS2#the-simple-way). |
@@ -1,6 +0,4 @@ | ||
Mustache | ||
======== | ||
# Mustache | ||
Mustache files are compiled with Twitter's wonderful [hogan.js](https://github.com/twitter/hogan.js). This is a fantastic compiler that easily supports client-side templates and has very straightforward options and good compile speed. | ||
Mustache files are compiled with twitter's wonderful [hogan.js](https://github.com/twitter/hogan.js). This is a fantastic compiler that easily supports client-side templates and has very straightforward options and good compile speed. | ||
The options you can pass can be [found here](https://github.com/twitter/hogan.js#compilation-options) and exactly mirror hogan's docs, other than `asString`, which is not necessary as this is covered by accord's adapter API. | ||
@@ -7,0 +5,0 @@ |
@@ -1,4 +0,5 @@ | ||
Myth | ||
==== | ||
# Myth | ||
Essentially a polyfill for the css future spec. Check the [features](https://github.com/segmentio/myth#features) to see what you can do with it. | ||
Myth is essentially a polyfill for the css future spec. It might be the simplest compiler in accord. It takes no options at all, just does it's thing whether you like it or not. Check the [features](https://github.com/segmentio/myth#features) to see what you can do with it. | ||
## Additional Options | ||
It takes no options at all - might be the simplest compiler in accord. |
@@ -1,8 +0,7 @@ | ||
SCSS | ||
==== | ||
# SCSS | ||
This adapter uses [node-sass](https://github.com/andrew/node-sass), an incredibly fast C binding to libsass. It is however limited in that it does not include ways to work with plugins and extensions that are as robust as the main ruby version, and that it only supports the scss syntax, and not sass. | ||
This adapter uses [node-sass](), an incredibly fast C binding to libsass. It is however limited in that it does not include ways to work with plugins and extensions that are as robust as the main ruby version, and that it only supports the scss syntax, and not sass. | ||
## Additional Options | ||
It has a pretty standard API, and uses the [options documented here](https://github.com/andrew/node-sass#options). Do not pass through `data` or `file`, as this will be overridden by accord's wrapper - everything else is fair game. | ||
It has a pretty standard API, and uses the [options documented here](https://github.com/andrew/node-sass#options. Do not pass through `data` or `file`, as this will be overridden by accord's wrapper -- everything else is fair game. | ||
If you do want to include plugins, you can start moving towards this type of functionality using the `importPaths` option -- by adding a folder to this path, you will make all its contents available for `@import`s into your scss files. While not quite as robust as stylus' options or sass-ruby's options, it will get the job done. | ||
If you do want to include plugins, you can start moving towards this type of functionality using the `importPaths` option - by adding a folder to this path, you will make all its contents available for `@import`s into your scss files. While not quite as robust as stylus' options or sass-ruby's options, it will get the job done. |
@@ -1,53 +0,58 @@ | ||
Stylus | ||
====== | ||
# Stylus | ||
The Stylus compiler interface is one of the most abnormal and has gone through heavy modification to fit to the the accord model. | ||
The stylus compiler interface is one of the most abnormal and has gone through heavy modification to fit to the the accord model. These docs describe how to correctly use the accord stylus adapter. | ||
## Additional Options | ||
### [set](http://learnboost.github.io/stylus/docs/js.html#setsetting-value) | ||
### [Define](http://learnboost.github.io/stylus/docs/js.html#definename-node) | ||
- key: `define` | ||
- type: `Object` | ||
- default: `{}` | ||
In stylus, you can use `set()` to set options directly on the compiler. The only time you will really ever need to use this is to set `filename`, and if you are using the `renderFile` method this is done automatically for you. So you probably won't ever need this. But if you do, you can `set` options by dropping the key/value pairs directly into the accord options object. | ||
`define` lets you pass in variables that you can use in Stylus. Pretty sweet. One thing to keep in mind is that Stylus does not do a great job of typecasting values that are passed in. For example, if you're working with colors, you need to go through quite a process to get the right values in. Eventually we'd like to add better typecasting to the accord adapter to make life easier, but for now you'll have to do it the long way. Let's look at an example with some basic values passed through. | ||
```coffee | ||
styl = accord.load('stylus') | ||
styl.render('.test\n foo: bar', { foo: 'bar', filename: 'none' }) | ||
.catch((err) -> console.error(err)) | ||
.done (css) -> console.log(css) | ||
styl.render( | ||
'.test\n width: maxwidth\n height: maxheight' | ||
define: | ||
maxwidth: 42 | ||
maxheight: 100 | ||
).catch( | ||
(err) -> console.error err | ||
).done( | ||
(css) -> console.log css | ||
) | ||
``` | ||
### [define](http://learnboost.github.io/stylus/docs/js.html#definename-node) | ||
You can pass as many key/value pairs as you want in the object, and each one will be defined. | ||
`define()` lets you pass in variables that you can use in stylus. Pretty sweet. One thing to keep in mind is that stylus does not do a great job of typecasting values that are passed in. For example, if you're working with colors, you need to go through quite a process to get the right values in. Eventually we'd like to add better typecasting to the accord adapter to make life easier, but for now you'll have to do it the long way. Let's look at an example with some basic values passed through. | ||
### [Include](http://learnboost.github.io/stylus/docs/js.html#includepath) | ||
- key: `include` | ||
- type: `(String|String[])` | ||
- default: `[]` | ||
```coffee | ||
styl = accord.load('stylus') | ||
styl.render('.test\n width: maxwidth\n height: maxheight', { define: { maxwidth: 42, maxheight: 100 } }) | ||
.catch((err) -> console.error(err)) | ||
.done (css) -> console.log(css) | ||
``` | ||
`include` will set additional paths in Stylus that you can `@import` from. For example, if you'd like to make a specific folder of Stylus available within another totally separate folder, you don't have to use path-fu on every `@import` statement, you can just add the folder's path with an `include` and then load it as if it was in the same folder. | ||
So define always is an object. If you pass in anything other than an object, you'll get nasty results. You can pass as many key/value pairs as you want in the object, and each one will be defined. | ||
### [include](http://learnboost.github.io/stylus/docs/js.html#includepath) | ||
`include()` will set additional paths in stylus that you can `@import` from. For example, if you'd like to make a specific folder of stylus available within another totally separate folder, you don't have to use path-fu on every `@import` statement, you can just add the folder's path with an `include()` and then load it as if it was in the same folder. For this and the next couple functions, you can either pass a single value or an array of values and each will be included as a path. | ||
```coffee | ||
styl = accord.load('stylus') | ||
styl.render('@import foobar', { include: __dirname + 'foobar' }) | ||
styl.render('@import foobar', include: __dirname + 'foobar') | ||
.catch((err) -> console.error(err)) | ||
.done (css) -> console.log(css) | ||
.done((css) -> console.log(css)) | ||
``` | ||
As mentioned earlier, if you want to include multiple paths, you can pass an array. | ||
As indicated by the type `String[]`, if you want to include multiple paths, you can pass an array. | ||
```coffee | ||
styl = accord.load('stylus') | ||
styl.render('@import baz', { include: [__dirname + 'foobar', __dirname + baz] }) | ||
.catch((err) -> console.error(err)) | ||
.done (css) -> console.log(css) | ||
styl.render('@import baz', include: [__dirname + 'foobar', __dirname + baz]) | ||
.catch((err) -> console.error err) | ||
.done((css) -> console.log css) | ||
``` | ||
### [import](http://learnboost.github.io/stylus/docs/js.html#importpath) | ||
### [Import](http://learnboost.github.io/stylus/docs/js.html#importpath) | ||
- key: `import` | ||
- type: `(String|String[])` | ||
- default: `[]` | ||
`import()` is exactly like include, except rather than just making the paths available, it will import all the files at the paths given automatically, so you don't have to use an `@import` at all in your stylus. It works the exact same as include, just a different name. | ||
`import` is like include, except rather than just making the paths available, it will import all the files at the paths given automatically, so you don't have to use an `@import` at all in your Stylus. | ||
@@ -58,15 +63,18 @@ ```coffee | ||
# single import | ||
styl.render('mixin_from_foobar()', { import: __dirname + 'foobar' }) | ||
.catch((err) -> console.error(err)) | ||
.done (css) -> console.log(css) | ||
styl.render('mixin_from_foobar()', import: __dirname + 'foobar') | ||
.catch((err) -> console.error err) | ||
.done((css) -> console.log css) | ||
# multiple imports | ||
styl.render('mixin_from_baz()', { import: [__dirname + 'foobar', __dirname + baz] }) | ||
.catch((err) -> console.error(err)) | ||
.done (css) -> console.log(css) | ||
styl.render('mixin_from_baz()', import: [__dirname + 'foobar', __dirname + baz]) | ||
.catch((err) -> console.error err) | ||
.done((css) -> console.log css) | ||
``` | ||
### [use](http://learnboost.github.io/stylus/docs/js.html#usefn) | ||
### [Use](http://learnboost.github.io/stylus/docs/js.html#usefn) | ||
- key: `use` | ||
- type: `(Function|Function[])` | ||
- default: `[]` | ||
Taking it up one more level, `use()` allows you to pass through a function which gets the entire stylus object, so you can add any number of additional `define`s, `include`s, `import`s, and whatever other javascript transformers you want. Best suited for stylus plugins that need to be loaded cleanly and make a few manipulations in the pipeline. `use` works the same as `include` or `import`, it just expects a function or array of functions. | ||
`use` allows you to pass through a function or array of functions which get(s) the entire Stylus object. So this function can add any number of additional `define`s, `include`s, `import`s, and whatever other JavaScript transformations you want. Best suited for Stylus plugins that need to be loaded cleanly and make a few manipulations in the pipeline (like [nib](https://github.com/visionmedia/nib) or [axis](https://github.com/jenius/axis)). | ||
@@ -79,10 +87,20 @@ ```coffee | ||
# single plugin | ||
styl.render('plugin()', { use: some_plugin() }) | ||
.catch((err) -> console.error(err)) | ||
.done (css) -> console.log(css) | ||
styl.render('plugin()', use: some_plugin()) | ||
.catch((err) -> console.error err) | ||
.done((css) -> console.log css) | ||
# multiple plugins | ||
styl.render('plugin()', { use: [some_plugin(), second_plugin()] }) | ||
.catch((err) -> console.error(err)) | ||
.done (css) -> console.log(css) | ||
styl.render('plugin()', use: [some_plugin, second_plugin]) | ||
.catch((err) -> console.error err) | ||
.done((css) -> console.log css) | ||
``` | ||
## [Set](http://learnboost.github.io/stylus/docs/js.html#setsetting-value) | ||
In Stylus, you can use `set()` to set options directly on the compiler. Accord lets you do this by dropping the key/value pairs directly into the options object. | ||
```coffee | ||
styl = accord.load('stylus') | ||
styl.render('.test\n foo: bar', foo: 'bar', filename: 'none') | ||
.catch((err) -> console.error err) | ||
.done((css) -> console.log css) | ||
``` |
@@ -68,2 +68,7 @@ // Generated by CoffeeScript 1.7.0 | ||
/** | ||
* @private | ||
*/ | ||
register_helpers = function(compiler, opts) { | ||
@@ -70,0 +75,0 @@ if (opts.helpers) { |
// Generated by CoffeeScript 1.7.0 | ||
(function() { | ||
var abstract_mapper, adapter_to_name, glob, name_to_adapter, path, resolve_path, supports, _; | ||
var abstract_mapper, adapter_to_name, glob, indx, name_to_adapter, path, resolve_path, supports, _; | ||
@@ -11,2 +11,4 @@ path = require('path'); | ||
indx = require('indx'); | ||
exports.supports = supports = function(name) { | ||
@@ -33,3 +35,3 @@ name = adapter_to_name(name); | ||
err = _error; | ||
throw new Error("'" + name + "' not found. make sure it has been installed!"); | ||
throw new Error("'" + pkg + "' not found. make sure it has been installed!"); | ||
} | ||
@@ -41,2 +43,16 @@ } | ||
exports.all = function() { | ||
return indx(path.join(__dirname, 'adapters')); | ||
}; | ||
/** | ||
* While almost certainly one of the ugliest functions I have written in my | ||
time, this little utility will get the exact path to the root folder of a | ||
node module from wherever it would be required from given it's name. | ||
* @param {String} name The name of the node module you want the path to. | ||
* @return {String} The root folder of node module `name`. | ||
* @private | ||
*/ | ||
resolve_path = function(name) { | ||
@@ -43,0 +59,0 @@ var i, p, _i, _len, _path; |
{ | ||
"name": "accord", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"author": "Jeff Escalante <hello@jenius.me>", | ||
"description": "A unified interface for compiled languages and templates in javascript", | ||
"main": "index.js", | ||
"description": "A unified interface for compiled languages and templates in JavaScript", | ||
"main": "lib", | ||
"license": "MIT", | ||
@@ -13,3 +13,2 @@ "repository": { | ||
"dependencies": { | ||
"coffee-script": "1.7.x", | ||
"colors": "0.6.x", | ||
@@ -19,10 +18,14 @@ "when": "3.x", | ||
"glob": "3.x", | ||
"uglify-js": "2.x" | ||
"uglify-js": "2.x", | ||
"indx": "0.1.x" | ||
}, | ||
"devDependencies": { | ||
"coffee-script": "1.7.x", | ||
"mocha": "*", | ||
"should": "*", | ||
"swig": "*", | ||
"jade": "*", | ||
"ejs": "*", | ||
"marked": "*", | ||
"marc": "*", | ||
"hogan.js": "*", | ||
@@ -29,0 +32,0 @@ "handlebars": "*", |
@@ -9,3 +9,3 @@ accord | ||
[![coverage](https://coveralls.io/repos/jenius/accord/badge.png?branch=master)](https://coveralls.io/r/jenius/accord?branch=master) | ||
[![dependencies](https://david-dm.org/jenius/accord.png)](https://david-dm.org/jenius/accord) | ||
[![dependencies](https://david-dm.org/jenius/accord.png?theme=shields.io)](https://david-dm.org/jenius/accord) | ||
@@ -94,9 +94,9 @@ ### Why should you care? | ||
- [haml](https://github.com/visionmedia/haml.js) | ||
- [swig](http://paularmstrong.github.io/swig) | ||
- [marc](https://github.com/bredele/marc) | ||
- nunjucks _(pending)_ | ||
- haml-coffee _(pending)_ | ||
- dust _(pending)_ | ||
- nunjucks _(pending)_ | ||
- underscore _(pending)_ | ||
- swig _(pending)_ | ||
- toffee _(pending)_ | ||
- marc _(pending)_ | ||
@@ -103,0 +103,0 @@ ##### CSS |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
168256
217
1179
28
11
+ Addedindx@0.1.x
+ Addedindx@0.1.2(transitive)
- Removedcoffee-script@1.7.x