mirror of https://github.com/sveltejs/svelte
				
				
				
			
						commit
						c84f120e4b
					
				@ -1,7 +1,9 @@
 | 
				
			||||
export function stringify(data: string) {
 | 
				
			||||
	return JSON.stringify(escape(data));
 | 
				
			||||
export function stringify(data: string, options = {}) {
 | 
				
			||||
	return JSON.stringify(escape(data, options));
 | 
				
			||||
}
 | 
				
			||||
 | 
				
			||||
export function escape(data: string) {
 | 
				
			||||
	return data.replace(/([^\\@#])?([@#])/g, '$1\\$2');
 | 
				
			||||
export function escape(data: string, { onlyEscapeAtSymbol = false } = {}) {
 | 
				
			||||
	return data.replace(onlyEscapeAtSymbol ? /(@+)/g : /(@+|#+)/g, (match: string) => {
 | 
				
			||||
		return match + match[0];
 | 
				
			||||
	});
 | 
				
			||||
}
 | 
				
			||||
 | 
				
			||||
@ -0,0 +1 @@
 | 
				
			||||
<a href='mailto:{{address}}'>email</a>
 | 
				
			||||
@ -0,0 +1,3 @@
 | 
				
			||||
export default {
 | 
				
			||||
	html: `<a href='mailto:hello@example.com'>email</a>`
 | 
				
			||||
};
 | 
				
			||||
@ -0,0 +1,9 @@
 | 
				
			||||
<Email address='hello@example.com'/>
 | 
				
			||||
 | 
				
			||||
<script>
 | 
				
			||||
	import Email from './Email.html';
 | 
				
			||||
 | 
				
			||||
	export default {
 | 
				
			||||
		components: { Email },
 | 
				
			||||
	};
 | 
				
			||||
</script>
 | 
				
			||||
					Loading…
					
					
				
		Reference in new issue