UNPKG

postcss-gtk

Version:

Processes GTK+ CSS into browser CSS

42 lines (36 loc) 1.24 kB
// Generated by CoffeeScript 1.9.1 (function() { var balanced, postcss, valueHook; balanced = require("balanced-match"); valueHook = require("./value-hook"); postcss = require("postcss"); module.exports = function(fn_name, fn) { return valueHook.add(function(str, node) { var arg, args, current_node, matches, post, pre, result, startIndex; startIndex = str.indexOf(fn_name + "("); if (startIndex === -1) { return str; } matches = balanced("(", ")", str.substring(startIndex)); if (matches) { args = postcss.list.comma(matches.body); args = (function() { var i, len, results; results = []; for (i = 0, len = args.length; i < len; i++) { arg = args[i]; results.push(valueHook.hook(arg)); } return results; })(); pre = str.slice(0, startIndex); post = str.substr(startIndex + matches.end + 1); current_node = node; result = fn.apply(null, args); return valueHook.hook(pre + result + post); } else { throw node.error(fn_name + "(): missing closing ')' in the value " + (JSON.stringify(str))); } }); }; }).call(this);