mirror of https://github.com/sveltejs/svelte
parent
4b3cacf3b9
commit
561ecf28ff
@ -1,18 +1,20 @@
|
|||||||
import { Parser } from '../index';
|
|
||||||
import { isIdentifierStart } from 'acorn';
|
import { isIdentifierStart } from 'acorn';
|
||||||
import full_char_code_at from '../../utils/full_char_code_at';
|
import full_char_code_at from '../../utils/full_char_code_at.js';
|
||||||
import {
|
import {
|
||||||
is_bracket_open,
|
is_bracket_open,
|
||||||
is_bracket_close,
|
is_bracket_close,
|
||||||
is_bracket_pair,
|
is_bracket_pair,
|
||||||
get_bracket_close
|
get_bracket_close
|
||||||
} from '../utils/bracket';
|
} from '../utils/bracket.js';
|
||||||
import { parse_expression_at } from '../acorn';
|
import { parse_expression_at } from '../acorn.js';
|
||||||
import { Pattern } from 'estree';
|
import parser_errors from '../errors.js';
|
||||||
import parser_errors from '../errors';
|
import { regex_not_newline_characters } from '../../utils/patterns.js';
|
||||||
import { regex_not_newline_characters } from '../../utils/patterns';
|
|
||||||
|
|
||||||
export default function read_context(parser: Parser): Pattern & { start: number; end: number } {
|
/**
|
||||||
|
* @param {import('../index.js').Parser} parser
|
||||||
|
* @returns {Pattern & { start: number; end: number }}
|
||||||
|
*/
|
||||||
|
export default function read_context(parser) {
|
||||||
const start = parser.index;
|
const start = parser.index;
|
||||||
let i = parser.index;
|
let i = parser.index;
|
||||||
|
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
import tag from './tag.js';
|
||||||
|
import mustache from './mustache.js';
|
||||||
|
import text from './text.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {import('../index.js').Parser} parser
|
||||||
|
*/
|
||||||
|
export default function fragment(parser) {
|
||||||
|
if (parser.match('<')) {
|
||||||
|
return tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parser.match('{')) {
|
||||||
|
return mustache;
|
||||||
|
}
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
@ -1,16 +0,0 @@
|
|||||||
import tag from './tag';
|
|
||||||
import mustache from './mustache';
|
|
||||||
import text from './text';
|
|
||||||
import { Parser } from '../index';
|
|
||||||
|
|
||||||
export default function fragment(parser: Parser) {
|
|
||||||
if (parser.match('<')) {
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (parser.match('{')) {
|
|
||||||
return mustache;
|
|
||||||
}
|
|
||||||
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
@ -1,7 +1,9 @@
|
|||||||
import { decode_character_references } from '../utils/html';
|
import { decode_character_references } from '../utils/html.js';
|
||||||
import { Parser } from '../index';
|
|
||||||
|
|
||||||
export default function text(parser: Parser) {
|
/**
|
||||||
|
* @param {import('../index.js').Parser} parser
|
||||||
|
*/
|
||||||
|
export default function text(parser) {
|
||||||
const start = parser.index;
|
const start = parser.index;
|
||||||
|
|
||||||
let data = '';
|
let data = '';
|
||||||
@ -1,6 +1,7 @@
|
|||||||
import { TemplateNode } from '../../interfaces';
|
/**
|
||||||
|
* @param {import("../../interfaces.js").TemplateNode} node
|
||||||
export function to_string(node: TemplateNode) {
|
*/
|
||||||
|
export function to_string(node) {
|
||||||
switch (node.type) {
|
switch (node.type) {
|
||||||
case 'IfBlock':
|
case 'IfBlock':
|
||||||
return '{#if} block';
|
return '{#if} block';
|
||||||
Loading…
Reference in new issue