Skip to content

Commit

Permalink
Regex license
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Seggewiß committed Aug 4, 2023
1 parent b8358f5 commit 2eeeb65
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ func main() {

fileContent := string(b)
// https://regex101.com/r/Q3VTcx/1
modelRegex := regexp.MustCompile(`(<` + componentName + `\n( *)[a-zA-Z0-9.\-:_$(')@!=>"{%} \n]*)v-model="(.*)"`)
modelRegex := regexp.MustCompile(`(<` + componentName + `\n( *)[a-zA-Z0-9.\-:_$(')@!=>"{%}\[\]? \n]*)v-model="(.*)"`)
modelFixed := modelRegex.ReplaceAllString(fileContent, "${1}{% if VUE3 %}\n${2}v-model:"+modelName+"=\"$3\"\n$2{% else %}\n${2}v-model=\"${3}\"\n${2}{% endif %}")

// https://regex101.com/r/VkXBIA/1
eventRegex := regexp.MustCompile(`(<` + componentName + `\n( *)[a-zA-Z0-9.\-:_$(')@!=>"{%} \n]*)@` + eventName + `="(.*)"`)
eventRegex := regexp.MustCompile(`(<` + componentName + `\n( *)[a-zA-Z0-9.\-:_$(')@!=>"{%}\[\]? \n]*)@` + eventName + `="(.*)"`)
eventFixed := eventRegex.ReplaceAllString(modelFixed, "${1}{% if VUE3 %}\n${2}@update:"+modelName+"=\"${3}\"\n${2}{% else %}\n${2}@"+eventName+"=\"${3}\"\n${2}{% endif %}")

err = os.WriteFile(file, []byte(eventFixed), 0644)
Expand Down

0 comments on commit 2eeeb65

Please sign in to comment.