refactor: ♻️ fragment types

pull/7685/head
chientrm 4 years ago
parent e973bacd38
commit a5f86c2cb4

@ -1,16 +1,10 @@
import tag from './tag'; import { Parser } from "../index";
import mustache from './mustache'; import mustache from "./mustache";
import text from './text'; import tag from "./tag";
import { Parser } from '../index'; import text from "./text";
export default function fragment(parser: Parser) { export default (parser: Parser) =>
if (parser.match('<')) { [
return tag; { match: "<", fragment: tag },
} { match: "{", fragment: mustache },
].find(({ match }) => parser.match(match))?.fragment ?? text;
if (parser.match('{')) {
return mustache;
}
return text;
}

Loading…
Cancel
Save