diff --git a/code/renderers/vue3/src/docs/sourceDecorator.test.ts b/code/renderers/vue3/src/docs/sourceDecorator.test.ts index 9ac045d2329..1d7d9d157c1 100644 --- a/code/renderers/vue3/src/docs/sourceDecorator.test.ts +++ b/code/renderers/vue3/src/docs/sourceDecorator.test.ts @@ -17,40 +17,40 @@ function generateMultiComponentForArgs(args: Args, slotProps: string[] | null = describe('generateSource Vue3', () => { test('boolean true', () => { expect(generateForArgs({ booleanProp: true })).toMatchInlineSnapshot( - `` + `` ); }); test('boolean false', () => { expect(generateForArgs({ booleanProp: false })).toMatchInlineSnapshot( - `` + `` ); }); test('null property', () => { expect(generateForArgs({ nullProp: null })).toMatchInlineSnapshot( - `` + `` ); }); test('string property', () => { expect(generateForArgs({ stringProp: 'mystr' })).toMatchInlineSnapshot( - `` + `` ); }); test('number property', () => { expect(generateForArgs({ numberProp: 42 })).toMatchInlineSnapshot( - `` + `` ); }); test('object property', () => { expect(generateForArgs({ objProp: { x: true } })).toMatchInlineSnapshot( - `` + `` ); }); test('multiple properties', () => { - expect(generateForArgs({ a: 1, b: 2 })).toMatchInlineSnapshot(``); + expect(generateForArgs({ a: 1, b: 2 })).toMatchInlineSnapshot(``); }); test('1 slot property', () => { expect(generateForArgs({ content: 'xyz', myProp: 'abc' }, ['content'])).toMatchInlineSnapshot(` - + {{ content }} `); @@ -58,7 +58,7 @@ describe('generateSource Vue3', () => { test('multiple slot property with second slot value not set', () => { expect(generateForArgs({ content: 'xyz', myProp: 'abc' }, ['content', 'footer'])) .toMatchInlineSnapshot(` - + `); @@ -66,7 +66,7 @@ describe('generateSource Vue3', () => { test('multiple slot property with second slot value is set', () => { expect(generateForArgs({ content: 'xyz', footer: 'foo', myProp: 'abc' }, ['content', 'footer'])) .toMatchInlineSnapshot(` - + @@ -75,7 +75,7 @@ describe('generateSource Vue3', () => { // test mutil components test('mutil component with boolean true', () => { expect(generateMultiComponentForArgs({ booleanProp: true })).toMatchInlineSnapshot( - `` + `` ); }); test('component is not set', () => { diff --git a/code/renderers/vue3/src/docs/sourceDecorator.ts b/code/renderers/vue3/src/docs/sourceDecorator.ts index cf13888f3d0..e067f396bde 100644 --- a/code/renderers/vue3/src/docs/sourceDecorator.ts +++ b/code/renderers/vue3/src/docs/sourceDecorator.ts @@ -9,6 +9,7 @@ import parserTypescript from 'prettier/parser-typescript.js'; import parserHTML from 'prettier/parser-html.js'; // eslint-disable-next-line import/no-extraneous-dependencies import { isArray } from '@vue/shared'; +import { Utils } from 'handlebars'; /** * Check if the sourcecode should be generated. * @@ -89,10 +90,6 @@ function propToDynamicSource( return `:${key}='()=>{}'`; } - if (typeof value === 'object') { - return `:${key}='${JSON.stringify(value)}'`; - } - return `:${key}='${JSON.stringify(value)}'`; } @@ -119,7 +116,7 @@ function propValueToSource(val: string | boolean | object | undefined) { case 'undefined': return `${val}`; default: - return `"${val}"`; + return `'${val}'`; } } @@ -234,10 +231,9 @@ function createNamedSlots( .filter((slotProp) => slotValues[slotProps.indexOf(slotProp)]) .map( (slotProp) => - `