mirror of https://github.com/sveltejs/svelte
parent
b7ec99e8c7
commit
231603df7b
@ -1,8 +1,8 @@
|
||||
import Renderer from '../Renderer';
|
||||
import { CompileOptions } from '../../../interfaces';
|
||||
import Renderer, { RenderOptions } from '../Renderer';
|
||||
import Comment from '../../nodes/Comment';
|
||||
|
||||
export default function(node, renderer: Renderer, options: CompileOptions) {
|
||||
export default function(node: Comment, renderer: Renderer, options: RenderOptions) {
|
||||
if (options.preserveComments) {
|
||||
renderer.append(`<!--${node.data}-->`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
export default function(node, renderer, options) {
|
||||
import Renderer, { RenderOptions } from '../Renderer';
|
||||
import Head from '../../nodes/Head';
|
||||
|
||||
export default function(node: Head, renderer: Renderer, options: RenderOptions) {
|
||||
renderer.append('${($$result.head += `');
|
||||
|
||||
renderer.render(node.children, options);
|
||||
|
||||
renderer.append('`, "")}');
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
import { snip } from '../../utils/snip';
|
||||
import Renderer, { RenderOptions } from '../Renderer';
|
||||
import RawMustacheTag from '../../nodes/RawMustacheTag';
|
||||
|
||||
export default function(node, renderer, options) {
|
||||
export default function(node: RawMustacheTag, renderer: Renderer, options: RenderOptions) {
|
||||
renderer.append('${' + snip(node.expression) + '}');
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,17 @@
|
||||
import { escape_html, escape_template, escape } from '../../utils/stringify';
|
||||
import Renderer, { RenderOptions } from '../Renderer';
|
||||
import Text from '../../nodes/Text';
|
||||
import Element from '../../nodes/Element';
|
||||
|
||||
export default function(node, renderer, options) {
|
||||
export default function(node: Text, renderer: Renderer, options: RenderOptions) {
|
||||
let text = node.data;
|
||||
if (
|
||||
!node.parent ||
|
||||
node.parent.type !== 'Element' ||
|
||||
(node.parent.name !== 'script' && node.parent.name !== 'style')
|
||||
((node.parent as Element).name !== 'script' && (node.parent as Element).name !== 'style')
|
||||
) {
|
||||
// unless this Text node is inside a <script> or <style> element, escape &,<,>
|
||||
text = escape_html(text);
|
||||
}
|
||||
renderer.append(escape(escape_template(text)));
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,10 @@
|
||||
export default function(node, renderer, options) {
|
||||
import Renderer, { RenderOptions } from '../Renderer';
|
||||
import Title from '../../nodes/Title';
|
||||
|
||||
export default function(node: Title, renderer: Renderer, options: RenderOptions) {
|
||||
renderer.append(`<title>`);
|
||||
|
||||
renderer.render(node.children, options);
|
||||
|
||||
renderer.append(`</title>`);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in new issue