File tree Expand file tree Collapse file tree 2 files changed +12
-16
lines changed Expand file tree Collapse file tree 2 files changed +12
-16
lines changed Original file line number Diff line number Diff line change 1- <script lang="ts">
2- import { Card , CardContent } from ' @/components/ui/card' ;
3- import { Badge } from ' @/components/ui/badge' ;
4-
5- export const components = {
6- ' sharp-card' : Card ,
7- ' sharp-card-content' : CardContent ,
8- ' sharp-badge' : Badge ,
9- };
10- </script >
111<script lang="ts" setup>
122 import { computed } from ' vue' ;
133 import type { Component } from ' vue' ;
4+ import { Card , CardContent } from " @/components/ui/card" ;
5+ import { Badge } from " @/components/ui/badge" ;
6+ import { sanitizeVueTemplate } from " @/utils/sanitize" ;
147
158 const props = defineProps <{
169 template: string ,
1912
2013 const component = computed (() => ({
2114 components: {
22- ... components ,
15+ ' sharp-card' : Card ,
16+ ' sharp-card-content' : CardContent ,
17+ ' sharp-badge' : Badge ,
2318 ... props .components ,
2419 },
25- template: ` <div data-sharp-template>${sanitizeForVue (props .template ?? ' ' )}</div> ` ,
20+ template: ` <div data-sharp-template>${sanitizeVueTemplate (props .template ?? ' ' )}</div> ` ,
2621 }));
27-
28- function sanitizeForVue(template : string ) {
29- return template .replaceAll (' {{' , ' {{' ).replaceAll (' }}' , ' }}' );
30- }
3122 </script >
3223
3324<template >
Original file line number Diff line number Diff line change @@ -13,3 +13,8 @@ export function sanitize(html: string | null) {
1313 } )
1414 : html ;
1515}
16+
17+ // Separate function that sanitizes all rendered Vue template, '{{' & '}}' should always be escaped
18+ export function sanitizeVueTemplate ( template : string ) {
19+ return template . replaceAll ( '{{' , '{{' ) . replaceAll ( '}}' , '}}' ) ;
20+ }
You can’t perform that action at this time.
0 commit comments