本文整理汇总了Golang中github.com/wendal/mustache.RenderString函数的典型用法代码示例。如果您正苦于以下问题:Golang RenderString函数的具体用法?Golang RenderString怎么用?Golang RenderString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了RenderString函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: MakeSummary
func MakeSummary(post Mapper, lines int, topCtx mustache.Context) string {
content := post["_content"].(*DocContent).Source
r := bufio.NewReader(bytes.NewBufferString(content))
dst := ""
for lines > 0 {
line, _ := r.ReadString('\n')
dst += line
lines--
if lines == 0 {
for "" != strings.Trim(line, "\r\n\t ") {
line, _ = r.ReadString('\n')
dst += line
}
}
}
str, err := mustache.RenderString(dst, topCtx)
if err != nil {
log.Println("BAD Mustache after Summary cut!")
str, err = mustache.RenderString(dst, topCtx)
if err != nil {
log.Println("BAD Mustache Summary?", err)
str = post["_content"].(*DocContent).Main
}
}
return MarkdownToHtml(str)
}
开发者ID:JoeyFan,项目名称:gor,代码行数:26,代码来源:compile.go
示例2: MakeSummary
func MakeSummary(post Mapper, lines int, topCtx mustache.Context) string {
content := post["_content"].(*DocContent).Source
r := bufio.NewReader(bytes.NewBufferString(content))
dst := ""
for lines > 0 {
line, _ := r.ReadString('\n')
dst += line
lines--
if lines == 0 {
for "" != strings.Trim(line, "\r\n\t ") {
line, _ = r.ReadString('\n')
dst += line
}
}
}
str, err := mustache.RenderString(dst, topCtx)
if err != nil {
log.Println("BAD Mustache after Summary cut!")
str, err = mustache.RenderString(dst, topCtx)
if err != nil {
log.Println("BAD Mustache Summary?", err)
str = post["_content"].(*DocContent).Main
}
}
mdParser := markdown.NewParser(&markdown.Extensions{Smart: true})
buf := bytes.NewBuffer(nil)
mdParser.Markdown(bytes.NewBufferString(str), markdown.ToHTML(buf))
return buf.String()
}
开发者ID:yemaocheng,项目名称:gor,代码行数:29,代码来源:compile.go
示例3: PrapreMainContent
func PrapreMainContent(id string, content string, ctx mustache.Context) (string, error) {
//mdParser := markdown.NewParser(&markdown.Extensions{Smart: true})
str, err := mustache.RenderString(content, ctx)
if err != nil {
return str, err
}
if strings.HasSuffix(id, ".md") || strings.HasSuffix(id, ".markdown") {
//log.Println("R: MD : " + id)
str = MarkdownToHtml(str)
}
return str, nil
}
开发者ID:JoeyFan,项目名称:gor,代码行数:12,代码来源:compile.go
示例4: PrapreMainContent
func PrapreMainContent(id string, content string, ctx mustache.Context) (string, error) {
str, err := mustache.RenderString(content, ctx)
if err != nil {
Log(INFO, "Error when parse %s", id)
return str, err
}
if strings.HasSuffix(id, ".md") || strings.HasSuffix(id, ".markdown") {
Log(DEBUG, "Read markdown: %s", id)
str = MarkdownToHtml(str)
}
return str, nil
}
开发者ID:newblue,项目名称:neyo,代码行数:12,代码来源:compile.go
示例5: MakeSummary
func MakeSummary(post Mapper, lines int, topCtx mustache.Context) string {
content := post["_content"].(*DocContent).Source
r := bufio.NewReader(bytes.NewBufferString(content))
dst := ""
readUntil := ""
for lines > 0 {
line, _ := r.ReadString('\n')
dst += line
lines--
if strings.Trim(line, "\r\n\t ") == "```" {
if readUntil == "" {
readUntil = "```"
} else {
readUntil = ""
}
}
if lines == 0 {
var err error
for readUntil != strings.Trim(line, "\r\n\t ") {
line, err = r.ReadString('\n')
dst += line
if err != nil {
break
}
}
}
}
str, err := mustache.RenderString(dst, topCtx)
if err != nil {
log.Println("BAD Mustache after Summary cut!")
str, err = mustache.RenderString(dst, topCtx)
if err != nil {
log.Println("BAD Mustache Summary?", err)
str = post["_content"].(*DocContent).Main
}
}
str = strings.Replace(str, TOC_MARKUP, "", 1)
return MarkdownToHtml(str)
}
开发者ID:29n,项目名称:gor,代码行数:39,代码来源:compile.go
示例6: PrapreMainContent
func PrapreMainContent(id string, content string, ctx mustache.Context) (string, error) {
mdParser := markdown.NewParser(&markdown.Extensions{Smart: true})
str, err := mustache.RenderString(content, ctx)
if err != nil {
return str, err
}
if strings.HasSuffix(id, ".md") || strings.HasSuffix(id, ".markdown") {
//log.Println("R: MD : " + id)
buf := bytes.NewBuffer(nil)
mdParser.Markdown(bytes.NewBufferString(str), markdown.ToHTML(buf))
str = buf.String()
}
return str, nil
}
开发者ID:yemaocheng,项目名称:gor,代码行数:14,代码来源:compile.go
示例7: RenderInLayout
func RenderInLayout(content string, layoutName string, layouts map[string]Mapper, ctx mustache.Context) (string, error) {
//log.Println("Render Layout", layoutName, ">>", content, "<<END")
ctx2 := make(map[string]string)
ctx2["content"] = content
layout := layouts[layoutName]
str, err := mustache.RenderString(layout["_content"].(*DocContent).Source, ctx2, ctx)
if err != nil {
return content, err
}
if layout.Layout() != "" {
return RenderInLayout(str, layout.Layout(), layouts, ctx)
}
return str, nil
}
开发者ID:yemaocheng,项目名称:gor,代码行数:14,代码来源:compile.go
注:本文中的github.com/wendal/mustache.RenderString函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论