-
Notifications
You must be signed in to change notification settings - Fork 473
fix: generate code should convert quote on vue template #1464
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
186e19d
fix: generate code should convert quote on vue template
chilingling 3b78770
fix: only save to state when contain both double and single quote
chilingling 8b4b104
feat(vue-generator): optimize quote escaping in template attributes a…
chilingling 6aa7278
fix: add fallback when generate state key fails
chilingling File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/vue-generator/test/testcases/sfc/templateQuote/components-map.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| [ | ||
| { | ||
| "componentName": "TinyButton", | ||
| "exportName": "Button", | ||
| "package": "@opentiny/vue", | ||
| "version": "^3.10.0", | ||
| "destructuring": true | ||
| } | ||
| ] |
27 changes: 27 additions & 0 deletions
27
packages/vue-generator/test/testcases/sfc/templateQuote/expected/jsxQuote.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| <template> | ||
| <div> | ||
| <tiny-grid :columns="state.columns"></tiny-grid> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup lang="jsx"> | ||
| import { Grid as TinyGrid } from '@opentiny/vue' | ||
| import * as vue from 'vue' | ||
| import { defineProps, defineEmits } from 'vue' | ||
| import { I18nInjectionKey } from 'vue-i18n' | ||
|
|
||
| const props = defineProps({}) | ||
|
|
||
| const emit = defineEmits([]) | ||
| const { t, lowcodeWrap, stores } = vue.inject(I18nInjectionKey).lowcode() | ||
| const wrap = lowcodeWrap(props, { emit }) | ||
| wrap({ stores }) | ||
|
|
||
| const state = vue.reactive({ | ||
| columns: [ | ||
| { field: 'info', title: '信息', slots: { default: ({ row }, h) => <span title='{"key": "value"}'></span> } } | ||
| ] | ||
| }) | ||
| wrap({ state }) | ||
| </script> | ||
| <style scoped></style> |
28 changes: 28 additions & 0 deletions
28
packages/vue-generator/test/testcases/sfc/templateQuote/expected/multiline.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| <template> | ||
| <div> | ||
| <tiny-button | ||
| multilineJson='{ | ||
| "name": "test", | ||
| "value": "data" | ||
| }' | ||
| :objWithMultiline="{ template: 'line1\nline2', label: 'normal' }" | ||
| ></tiny-button> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup> | ||
| import * as vue from 'vue' | ||
| import { defineProps, defineEmits } from 'vue' | ||
| import { I18nInjectionKey } from 'vue-i18n' | ||
|
|
||
| const props = defineProps({}) | ||
|
|
||
| const emit = defineEmits([]) | ||
| const { t, lowcodeWrap, stores } = vue.inject(I18nInjectionKey).lowcode() | ||
| const wrap = lowcodeWrap(props, { emit }) | ||
| wrap({ stores }) | ||
|
|
||
| const state = vue.reactive({}) | ||
| wrap({ state }) | ||
| </script> | ||
| <style scoped></style> |
29 changes: 29 additions & 0 deletions
29
packages/vue-generator/test/testcases/sfc/templateQuote/expected/primitiveQuote.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| <template> | ||
| <div> | ||
| <tiny-button | ||
| noQuotes="plain text value" | ||
| onlyDouble='{"name": "test", "id": "main"}' | ||
| onlySingle="it's a 'test' value" | ||
| bothQuotes='She said "hello" and it's fine' | ||
| htmlAttr='class="primary" id="btn-1"' | ||
| emptyStr="" | ||
| ></tiny-button> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup> | ||
| import * as vue from 'vue' | ||
| import { defineProps, defineEmits } from 'vue' | ||
| import { I18nInjectionKey } from 'vue-i18n' | ||
|
|
||
| const props = defineProps({}) | ||
|
|
||
| const emit = defineEmits([]) | ||
| const { t, lowcodeWrap, stores } = vue.inject(I18nInjectionKey).lowcode() | ||
| const wrap = lowcodeWrap(props, { emit }) | ||
| wrap({ stores }) | ||
|
|
||
| const state = vue.reactive({}) | ||
| wrap({ state }) | ||
| </script> | ||
| <style scoped></style> |
31 changes: 31 additions & 0 deletions
31
packages/vue-generator/test/testcases/sfc/templateQuote/expected/quoteScope.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| <template> | ||
| <div> | ||
| <tiny-button | ||
| jsonContent='{"key": "value", "nested": "data"}' | ||
| mixedQuotes="She said "hello" and he said 'hi'" | ||
| :filteredItems="state.items.filter((i) => i.name === 'test' && i.tag === 'featured')" | ||
| ></tiny-button> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup> | ||
| import * as vue from 'vue' | ||
| import { defineProps, defineEmits } from 'vue' | ||
| import { I18nInjectionKey } from 'vue-i18n' | ||
|
|
||
| const props = defineProps({}) | ||
|
|
||
| const emit = defineEmits([]) | ||
| const { t, lowcodeWrap, stores } = vue.inject(I18nInjectionKey).lowcode() | ||
| const wrap = lowcodeWrap(props, { emit }) | ||
| wrap({ stores }) | ||
|
|
||
| const state = vue.reactive({ | ||
| items: [ | ||
| { name: 'test', tag: 'featured' }, | ||
| { name: 'hello', tag: 'normal' } | ||
| ] | ||
| }) | ||
| wrap({ state }) | ||
| </script> | ||
| <style scoped></style> |
65 changes: 65 additions & 0 deletions
65
packages/vue-generator/test/testcases/sfc/templateQuote/expected/templateQuote.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| <template> | ||
| <div> | ||
| <tiny-button | ||
| v-for="(item, index) in [ | ||
| { | ||
| type: 'primary', | ||
| subStr: 'primary\'subStr\'' | ||
| }, | ||
| { | ||
| type: '' | ||
| }, | ||
| { | ||
| type: 'info' | ||
| }, | ||
| { | ||
| type: 'success' | ||
| }, | ||
| { | ||
| type: 'warning' | ||
| }, | ||
| { | ||
| type: 'danger' | ||
| } | ||
| ]" | ||
| type="primary" | ||
| text="test" | ||
| subStr="pri"ma"ry'subStr'" | ||
| :customExpressionTest="{ | ||
| value: [ | ||
| { | ||
| defaultValue: '{"class": "test-class", "id": "test-id"}' | ||
| } | ||
| ] | ||
| }" | ||
| :customAttrTest="{ | ||
| value: [ | ||
| { | ||
| defaultValue: | ||
| '{"class": "test-class", "id": "test-id", "class2": "te\'st\'-class2"}', | ||
| subStr: 'test-\'cl\'ass2' | ||
| } | ||
| ] | ||
| }" | ||
| ></tiny-button> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup> | ||
| import * as vue from 'vue' | ||
| import { defineProps, defineEmits } from 'vue' | ||
| import { I18nInjectionKey } from 'vue-i18n' | ||
|
|
||
| const props = defineProps({}) | ||
|
|
||
| const emit = defineEmits([]) | ||
| const { t, lowcodeWrap, stores } = vue.inject(I18nInjectionKey).lowcode() | ||
| const wrap = lowcodeWrap(props, { emit }) | ||
| wrap({ stores }) | ||
|
|
||
| const state = vue.reactive({ | ||
| customAttrTest: { value: [{ defaultValue: '{"class": "test-class", "id": "test-id"}' }] } | ||
| }) | ||
| wrap({ state }) | ||
| </script> | ||
| <style scoped></style> |
9 changes: 9 additions & 0 deletions
9
packages/vue-generator/test/testcases/sfc/templateQuote/jsxQuote.components-map.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| [ | ||
| { | ||
| "componentName": "TinyGrid", | ||
| "exportName": "Grid", | ||
| "package": "@opentiny/vue", | ||
| "version": "^3.10.0", | ||
| "destructuring": true | ||
| } | ||
| ] |
45 changes: 45 additions & 0 deletions
45
packages/vue-generator/test/testcases/sfc/templateQuote/jsxQuote.schema.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| { | ||
| "state": { | ||
| "columns": [ | ||
| { | ||
| "field": "info", | ||
| "title": "信息", | ||
| "slots": { | ||
| "default": { | ||
| "type": "JSSlot", | ||
| "value": [ | ||
| { | ||
| "componentName": "span", | ||
| "props": { | ||
| "title": "{\"key\": \"value\"}" | ||
| }, | ||
| "id": "jsx-span-001", | ||
| "children": [] | ||
| } | ||
| ], | ||
| "params": ["row"] | ||
| } | ||
| } | ||
| } | ||
| ] | ||
| }, | ||
| "methods": {}, | ||
| "componentName": "Page", | ||
| "css": "", | ||
| "props": {}, | ||
| "lifeCycles": {}, | ||
| "children": [ | ||
| { | ||
| "componentName": "TinyGrid", | ||
| "props": { | ||
| "columns": { | ||
| "type": "JSExpression", | ||
| "value": "state.columns" | ||
| } | ||
| }, | ||
| "id": "jsx-test-001", | ||
| "children": [] | ||
| } | ||
| ], | ||
| "fileName": "testJsxQuote" | ||
| } |
23 changes: 23 additions & 0 deletions
23
packages/vue-generator/test/testcases/sfc/templateQuote/multiline.schema.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "state": {}, | ||
| "methods": {}, | ||
| "componentName": "Page", | ||
| "css": "", | ||
| "props": {}, | ||
| "lifeCycles": {}, | ||
| "children": [ | ||
| { | ||
| "componentName": "TinyButton", | ||
| "props": { | ||
| "multilineJson": "{\n \"name\": \"test\",\n \"value\": \"data\"\n}", | ||
| "objWithMultiline": { | ||
| "template": "line1\nline2", | ||
| "label": "normal" | ||
| } | ||
| }, | ||
| "id": "multiline-test-001", | ||
| "children": [] | ||
| } | ||
| ], | ||
| "fileName": "testMultiline" | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.