Last active
August 29, 2015 14:20
-
-
Save FireNeslo/a11455ee7f76c1b7ab9a to your computer and use it in GitHub Desktop.
browserify transform for ruby style symbols
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var through = require('through2'); | |
var symbols = /¤([^\s,:;()\[\]{}=]+)/g | |
function strings(string, match) { | |
return "'" + match + "'" | |
} | |
module.exports = function (file) { | |
return through(function (buffer, enc, next) { | |
var input = buffer.toString('utf8') | |
var output = input.replace(symbols, strings); | |
this.push(output) | |
next(); | |
}); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro to_str { | |
case { _ ($toks ...) } => { | |
return [makeValue(#{ $toks ... }.map(unwrapSyntax).join(''), #{ here })]; | |
} | |
} | |
operator (:) 14 { $key } => #{ to_str $key } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment