Skip to content
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

feat: custom template delimiter #50

Closed
wants to merge 2 commits into from

Conversation

LiusCraft
Copy link
Contributor

default delimiter: {{ }}

set delims: yap.SetDelims("${", "}$") or setDelims "${", "}$"

@LiusCraft LiusCraft force-pushed the feat/template-delimiter branch from 13e43e7 to f8bb7c0 Compare February 1, 2024 08:45
@@ -82,6 +82,12 @@ func (p *App) Static__2(pattern string, fs http.FileSystem, allowRedirect ...boo
p.StaticHttp(pattern, fs, allowRedirect...)
}

// custom delimiter,
// example:{{ }} => ${ }$
func (p *App) SetDelims(left, right string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why we should support custom delimiter?

Copy link
Contributor Author

@LiusCraft LiusCraft Feb 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

scene

It conflicts with yap
vue:

<script setup>
import { ref } from 'vue'
const message = ref('Hello World!')
</script>
<template>
  <h1>{{ message }}</h1>
</template>

to prevent conflicts with the front-end framework, developers can decide to change delimiter of the template
example vue:
goplus/community#63 (comment)

Additionally, most go web frameworks support modifying delimiters.

gin: https://github.com/gin-gonic/gin/blob/v1.9.1/gin.go#L239
beego: https://pkg.go.dev/github.com/astaxie/beego#WebConfig.TemplateLeft

@xushiwei PTAL

@xushiwei
Copy link
Member

xushiwei commented Mar 9, 2024

YAP doesn't want to support custom delimiter since html/template doesn't support it.

@xushiwei xushiwei closed this Mar 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants