Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hughsk/sweetify
A browserify transform for sweet.js
https://github.com/hughsk/sweetify
Last synced: 8 days ago
JSON representation
A browserify transform for sweet.js
- Host: GitHub
- URL: https://github.com/hughsk/sweetify
- Owner: hughsk
- License: other
- Created: 2013-08-03T14:13:11.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-06-10T21:29:35.000Z (over 10 years ago)
- Last Synced: 2024-10-17T16:37:24.712Z (22 days ago)
- Language: JavaScript
- Size: 117 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# sweetify [![deprecated](http://badges.github.io/stability-badges/dist/deprecated.svg)](http://github.com/badges/stability-badges) #
**This module has been replaced by [@andreypopp](http://github.com/andreypopp)'s implementation, which [you can find here](http://github.com/andreypopp/sweetify).**
A [browserify](http://browserify.org/) transform for
[sweet.js](http://sweetjs.org/), which brings hygienic macros to JavaScript.## Installation ##
``` bash
npm install sweetify
```## Usage ##
``` bash
browserify -t sweetify index.sjs
```### `require.macro(file)` ###
You might want to have to avoid copying and pasting your macros between files,
so included is an unofficial means to `require` them into your script.Take, for example, `first.sjs`:
``` javascript
// first.sjs
macro first {
case ($a + $b) => { $a }
}
```You can use `require.macro` to include its contents in your script.
``` javascript
// index.sjs
require.macro('./first.sjs')var x = first(1 + 2)
console.log(x)
```Bundling `index.sjs` will result in output along these lines:
``` javascript
// bundle.js
var x$2 = 1;
console.log(1);
````require.macro` uses [browser-resolve](http://ghub.io/browser-resolve) to find
the file too, so you can throw your macros up on NPM if you so please.Note however that inlining is pretty rudimentary: it literally prepends the
file contents to your script before passing it to sweet.js. Pull requests are
welcome if you find a way to bend the parser to exclude everything but the
macros, or any other improvements you can think of :)