You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
683 B
30 lines
683 B
"use strict";
|
|
|
|
const postcssParse = require("postcss/lib/parse");
|
|
const TemplateParser = require("./template-parser");
|
|
const TemplateSafeParser = require("./template-safe-parser");
|
|
const Input = require("postcss/lib/input");
|
|
|
|
function templateParse(css, opts, Parser) {
|
|
const input = new Input(css, opts);
|
|
|
|
const parser = new Parser(input);
|
|
parser.parse();
|
|
|
|
return parser.root;
|
|
}
|
|
|
|
module.exports = function buildTemplateSyntax(baseSyntax) {
|
|
return {
|
|
parse(css, opts) {
|
|
return templateParse(
|
|
css,
|
|
opts,
|
|
baseSyntax.parse === postcssParse ? TemplateParser : TemplateSafeParser
|
|
);
|
|
},
|
|
stringify(...args) {
|
|
return baseSyntax.stringify(...args);
|
|
},
|
|
};
|
|
};
|
|
|