Code Monkey home page Code Monkey logo

gorazor's People

Contributors

bom-d-van avatar bronze1man avatar chenyukang avatar kzbt avatar nextzhou avatar sunfmin avatar testwill avatar wuvist avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gorazor's Issues

Sublime Text高亮问题

screenshot170

如果直接使用'@for'之类的话后面不会高亮

版本为Sublime Text 3 Build 3065

未测试Sublime Text 2是否有此现象

所有高亮主题都会出现

Escaping doesn't work well

@variable will automatically escape the variable, but I found that the escaping doesn't work in layout.

Import models from main package

Hello!

I'm sorry for the silly question, but is it possible to declare model variables from main package? If yes, how could I call it?

The problem is, I want to send an interface with a map like Content{var, var, var, map}
but in the end get "undefined map" error

Also, might be a good idea to add examples of models to examples, I'm missing the model code from your example packages :(

Thanks.

\ not escaped

<script type="text/javascript">console.log("\n");</script>

is producing

_buffer.WriteString("<script type=\"text/javascript\">console.log(\"\n\");</script>")

it should produce:

_buffer.WriteString("<script type=\"text/javascript\">console.log(\"\\n\");</script>")

if 语句编译bug

@if x==0 {class="aaa"}

期望的输出是:
if x == 0 {
_buffer.WriteString("class="aaa"")
}

目前的输出是:
if x == 0 {
class = "aaa"
}

少了 _buffer.WriteString()

bug (?) with @raw and variable.variable in range

Say, I have this code:

@{
        for _, v := range p.Posts {
                <h1>@raw(v.Title)</h1>
                <p>@raw(v.Content)</h1>
        }
    }

v.Title and v.Content vars do not produce raw results (gorazor and HTMLEscape is still used after recompile).

代码块生成后多出无用花括号

@{
    isActive := func(name string) {
        if active == name {
            <li class="active">
        }else{
            <li>
        }
    }
}

生成.go后

    {
        isActive := func(name string) {
            if active == name {

                _buffer.WriteString("<li class=\"active\">\n        ")
            } else {

                _buffer.WriteString("<li>\n     ")
            }
        }
    }

导致出现isActive未定义错误

Extra whitespaces in output

in lexer.go
line: text = strings.Replace(lexer.Text, "\r", "\n", -1)
should be: text = strings.Replace(text, "\r", "\n", -1)

or maybe just remove that line and replace line above with: text := strings.Replace(lexer.Text, "\r", "", -1)

Change the file case of the gohtml file,build the go file in mac,push it to a git ,pull that git in linux,and build the go file again,you will get two golang files with file case different.And the package will not compile in linux

只修改gohtml文件的大小写,然后在mac里面生成模板,传到git里面.再到linux里面拉取,然后会生成2个大小写不一样的go文件导致无法编译.
Change the file case of the gohtml file,build the go file in mac,push it to a git ,pull that git in linux,and build the go file again,you will get two golang files with file case different.And the package will not compile in linux.

请教gorazor模板几个基本问题: 作用域传递

衡量一个模板是否好用,非 Hello World 所能反映出来的,必须在深入使用,才能体会。
我在实际使用go template 时遇到几个问题,想问问 gorazor 是什么解决的。

我都是基于 golang template 来说的.

  1. 作用域传递问题
    parent.tpl:
  {{range .Students}}
  {{template "child" .}}
  {{end}}
  <img src="{{$.CDN}}{{.Logo}}">

child.tpl:

  <p>{{.Name}}</p>
  <img src="{{$.CDN}}{{.Pic}}">

xx.go

  if request.URL == "" {
      m.CDN = "http://cdn.xxx.com"
  } else {
      m.CDN = ""
  }

  m.Logo = "/pics/logo.png"
  m.Students = []Students{{Name:"smith","Pic":"/pics/smith.jpg"},{Name:"fox","Pic":"/pics/fox.jpg"}}
  render("parent.tpl", m)

具体问题: child.tpl 的 {{$.CDN}} 会报错。
本质问题: 子模板被引用后,内部的最高作用域 root 是parent传入的变量,但实际应用还需要 glob 这样的作用域

基于go template我能想到的解决方法都有问题:

  1. 无论多少级的引用都传 . ,保证每层的tpl的root实际是 glob,但大大减低了 复用
  2. 不在模板解决,而在代码层解决,但这个func必须带入 http 上下文,不是一个 util function

参考nuxt.js做服务器端渲染框架?

go写api非常棒,但是做web开发,由于官方模板的问题,大大限制了go的发挥。

很多人前端用Vue(或react)+后端go服务器端。这个办法实现前后端分离,但是对seo不友好,学习成本也挺高。接着又有了基于vue上的nuxt。在服务器端渲染,虽然解决seo的问题,但是还是不够简单高效。

既然是服务器端渲染,何必还要靠js呢?不如直接go实现?gorazor本质就是干这个事的啊!
相比nuxt,go做服务器端渲染至少有这些优势:1.更简单,无需学习vue一套东西,学习成本低。2.更高效,go的运行效率肯定比js高。3.更清爽,用go写代码,无疑爽多了。4.更好调试。

所以是否可以考虑参考nuxt.js,做go版本的服务器端渲染框架?彻底解决go模板渲染的问题,为go补齐一个短板。

Plain string "for" caused generated can't compiled code

code:

@{
    var l *Locale
}
<span>@l.T(`for`)</span>

Will generate:

package test
import (
"github.com/sipin/gorazor/gorazor"
"bytes"

)
func S(l *Locale) string {
var _buffer bytes.Buffer
_buffer.WriteString("\n<span>")
_buffer.WriteString(gorazor.HTMLEscape(l.T(`for`
)))
_buffer.WriteString("</span>")


return _buffer.String()
}


which can't compile because:

FelixMBPR:Desktop sunfmin$ gorazor test/ test/
Processing dir: test/ test/
Processing: test/s.gohtml --> /Users/sunfmin/Desktop/test/s.go
/Users/sunfmin/Desktop/test/s.go:10:49: missing ',' before newline in argument list
gofmt:  exit status 2


Another parsing bug

@section js {
    <script src="/js/jquery.rwdImageMaps.min.js"></script>
    @if custom["js"] != "" {
        <script src="@custom["js"]"></script>
    }
    <script type="text/javascript">
        $(document).ready(function(e) {
            $('img[usemap]').rwdImageMaps();
        });
    </script>
}

gives

    js := func() string {
        var _buffer bytes.Buffer

        _buffer.WriteString("<script src=\"/js/jquery.rwdImageMaps.min.js\"></script>")

        if custom["js"] != "" {

            _buffer.WriteString("<script src=\"")
            _buffer.WriteString(gorazor.HTMLEscape(custom["js"]))
            _buffer.WriteString("\"></script>")

            return _buffer.String()
        }

        _buffer.WriteString("<script type=\"text/javascript\">\n        $(document).ready(function(e) {\n           $('img[usemap]').rwdImageMaps();\n      });\n   </script>")

    }

should be

    js := func() string {
        var _buffer bytes.Buffer

        _buffer.WriteString("<script src=\"/js/jquery.rwdImageMaps.min.js\"></script>")

        if custom["js"] != "" {

            _buffer.WriteString("<script src=\"")
            _buffer.WriteString(gorazor.HTMLEscape(custom["js"]))
            _buffer.WriteString("\"></script>")

        }

        _buffer.WriteString("<script type=\"text/javascript\">\n        $(document).ready(function(e) {\n           $('img[usemap]').rwdImageMaps();\n      });\n   </script>")
        return _buffer.String()
    }

Code block variables doesn't expose to below template

code

@{
    import (
        "github.com/sunfmin/gorazortests/models"
    )

}

@{
au := &models.Author{"Van", 20}
}


<body>
@raw(Hello("Felix Sun", "h1", 30, au ,10))
</body>

generate:

package templates

import (
    "bytes"
    "github.com/sunfmin/gorazortests/models"
)

func Invokehello() string {
    var _buffer bytes.Buffer
    _buffer.WriteString("\n\n")
    {
        au := &models.Author{"Van", 20}
    }
    _buffer.WriteString("\n\n\n<body>\n")
    _buffer.WriteString((Hello("Felix Sun", "h1", 30, au, 10)))
    _buffer.WriteString("\n</body>\n\n")

    return _buffer.String()
}


compiles error:

sunfmin@FelixMBPR ~/gopkg/src/github.com/sunfmin/gorazortests> gorazor ./templates/ ./templates/ ; go run main.go 
Processing dir: ./templates/ ./templates/
Processing: templates/hello.gohtml --> /Users/sunfmin/gopkg/src/github.com/sunfmin/gorazortests/templates/hello.go
Processing: templates/invokehello.gohtml --> /Users/sunfmin/gopkg/src/github.com/sunfmin/gorazortests/templates/invokehello.go
# github.com/sunfmin/gorazortests/templates
templates/invokehello.go:15: undefined: au


How to use it to template a variable in url?

I have following php template, I am trying to translate to gorazor template.

<img src="/public/image/login-image-<?php echo rand(1,5);?>.jpg" alt="Login Full Background" class="full-bg animation-pulseSlow">

I have tried this:

@{
    import (
        "github.com/bronze1man/kmg/kmgRand"
    )
}
<img src="/public/image/[email protected](0,5).jpg" alt="Login Full Background" class="full-bg animation-pulseSlow">

It will product:

package Tpl

import (
    "bytes"
    "github.com/bronze1man/kmg/kmgRand"
    "github.com/sipin/gorazor/gorazor"
)

func AdminLoginPage() string {
    var _buffer bytes.Buffer
    _buffer.WriteString("\n<img src=\"/public/image/login-image-")
    _buffer.WriteString(gorazor.HTMLEscape(kmgRand.IntBetween(0, 5).jpg))
    _buffer.WriteString("\" alt=\"Login Full Background\" class=\"full-bg animation-pulseSlow\">")

    return _buffer.String()
}

some char in template can cause compiled go file can not runable.

template

value=\"<?= h(aabasdf\Admin\Document::$asdf) ?>\"/>\n

compiled go file:

package tpl
import (
"bytes"

)
func FailTest() string {
var _buffer bytes.Buffer
_buffer.WriteString("value=\\"<?= h(aabasdf\Admin\Document::$asdf) ?>\\"/>\")


return _buffer.String()
}

compiled failed info:

/xxx/tpl/failTest.go:8:32: illegal character U+003F '?'
/xxx/tpl/failTest.go:8:44: illegal character U+005C '\'
/xxx/tpl/failTest.go:8:50: illegal character U+005C '\'
/xxx/tpl/failTest.go:8:61: illegal character U+0024 '$'
/xxx/tpl/failTest.go:8:68: illegal character U+003F '?'
/xxx/tpl/failTest.go:8:70: illegal character U+005C '\'
/xxx/tpl/failTest.go:8:71: illegal character U+005C '\'
/xxx/tpl/failTest.go:8:72: string literal not terminated
/xxx/tpl/failTest.go:11:1: expected ')', found 'return'
/xxx/tpl/failTest.go:12:3: expected '}', found 'EOF'

Parser erro

@{
    import (
        "zfw/models"
        . "zfw/tplhelper"
        "dm"
    )
    var obj *models.Widget
}

@{
    data, dmType := dm.GetData(obj.PlaceHolder)

    if dmType == "simple" {
        obj.StringList = data.([]string)
        <div>@raw(SelectPk(obj))</div>
    } else {
        node := data.(*dm.DMTree)
<div class="form-group @GetErrorClass(obj)">
    <label for="@obj.Name" class="col-sm-2 control-label">@obj.Label</label>
    <div class="col-sm-10">
        <select class="form-control" name="@obj.Name" @BoolStr(obj.Disabled, "disabled")>
        @for _, option := range node.Keys{
            if option == obj.Value{
                <option selected>@option</option>
            }else{
                <option>@option</option>
            }
        }
        </select>
        @if obj.ErrorMsg != "" {
        <span class="label label-danger">@obj.ErrorMsg</span>
        }
    </div>
</div>

    }
}

请教gorazor模板几个基本问题: 基于变量多选一的逻辑

衡量一个模板是否好用,复用是一个非常重要的指标,非 Hello World 所能反映出来的,必须在深入使用,才能体会。
我想请教几个问题,想问问 gorazor 是什么解决的。

我都是基于 golang template 来说的.

  1. 在模板中基于变量多选一的逻辑
      <select>
      <option value="-1">all</option>
      <option value="4"  {{if eq .item.Value 4}}  selected="selected"{{end}}>a</option>
      <option value="9"  {{if eq .item.Value 9}}  selected="selected"{{end}}>b</option>
      <option value="11" {{if eq .item.Value 11}} selected="selected"{{end}}>c</option>
      <option value="3"  {{if eq .item.Value 3}}  selected="selected"{{end}}>d</option>
      </select>

这样的代码既丑陋又低效,gorazor 能解决吗?

Can't find layout: project/internal/app/templates/layout/base

I'm able to import project/internal/app/templates/helper and use imported classes without issue

index.gohtml

@{
  import (
    "project/internal/app/templates/helper"
  )
}

@helper.Test("helper")
<div>content</div>

I've created a layout in templates/layout/Base.gohtml:

<div>!!!</div>

When I change index.gohtml's first lines to the following:

@{
  import (
    "project/internal/app/templates/helper"
    "project/internal/app/templates/layout"
  )
  layout := layout.Base
}

It throws

Can't find layout: project/internal/app/templates/layout/base

I tried copying the example templates from the example directory to my project's tpl (fixing the packages), and get the same error.

sections from layout seem to be required

If I have a layout:

@{
    var body string
    var js string
}

hello @js

And in another template do not use

@section js {
    world
}

I get a not enough arguments in call to layout.App`` because the compiled template is callingreturn layout.App(_buffer.String())```

The docs state that the layout sections are optional, so is this a bug or am I reading the docs incorrectly? Thanks for an awesome library!

License GoRazor?

Hi GoRazor Team,

Can you add some license information into the project?

The GoLang project uses a 3-clause BSD license. If you don't have any preferences would you consider a BSD license or an Apache License?

Thanks!

-Erik

I can't seem to get the packages right.

Today gorazor command sources files from 'tpl' and create a new folder 'gen' with files packaged as 'tpl'.

Is this correct? Shouldn't the generated code be packaged as the same output folder?

Thanks

请教gorazor模板几个基本问题: 网页的错误页面

一般网站在发生内部错误的时候会统一跳转到一个错误页面。所以会有一个统一的入口和实现。用 go native template 实现的伪代码:
basepage.go

  package base
  func Error(errcode int, errmsg string) {
        data.User = currentUser
        data.HasNewMessage = false
        data.SomeOtherBussinesData = xxx
        gotemplate.Render("error.tpl", data)
  }

这个思路在很多模板系统是流行的解决方法,能统一处理所有页面处理时出错 渲染 Error Page

用gorazor按这个思路做不了,比如伪代码类似
gorazor_basepage.go

  package base
  import "gorazor_gentpl"

  func Error(errcode int, errmsg string) {
        data.User = currentUser
        data.HasNewMessage = false
        data.SomeOtherBussinesData = xxx
        gorazor_gentpl.Error(data)
  }

gorazor_gentpl 这里面的代码有 import 了 base 里的不少东西。

问题的本质: go native tempate 非代码运行,虽然tpl引用了base,但 base 内再 call tpl 没问题。但gorazor是代码运行就有package 相互 import 的问题。

我能想到的解决方法:

  1. 将 Error 做的很简单,不用 模板系统。 这种改动有点本末倒置,让用户体验服从框架。
  2. 将 Error 的模板引用到的东西再抽成一个 package,base 也 import 这个package
    这个思路貌似可行,但是 package 是目录级别的,得要考虑同目录下go文件的 import,牵扯有点多,而且这会导致后面很多代码都提心吊胆。

不知道 gorazor 如何解决这个问题的

Request: Add "Line Directives"

Great project! This makes it easy to move from ASP.NET MVC to GO.
One request I have is to add Go's undocumented "line directives" to the generated code so Go’s error reporting can reference your original source:

//line index.ego:1
func RenderIndex(w io.Writer, widgets []*Widget) error {
//line index.ego:2
    _, _ = fmt.Fprintf(w, "\n\n<html>\n<body>\n  <h1>Widgets for Sale!</h1>\n\n  <ul>\n    ")
//line index.ego:8
    for _, widget := range widgets {
//line index.ego:9
        _, _ = fmt.Fprintf(w, "\n      <li>")
//line index.ego:9
        _, _ = fmt.Fprintf(w, "%v", widget.Name)
//line index.ego:9
        _, _ = fmt.Fprintf(w, " for $")
//line index.ego:9
        _, _ = fmt.Fprintf(w, "%v", widget.Price)
//line index.ego:9
        _, _ = fmt.Fprintf(w, "</li>\n    ")
//line index.ego:10
    }
//line index.ego:11
    _, _ = fmt.Fprintf(w, "\n  </ul>\n</body>\n</html>\n")
    return nil
}

The above code is from an article on the EGO templating engine.

Should it preserve newline and whitespace?

hello_gohtml__gorazortests

But it generates:

<ul><li> Felix Sun 0 </li><li> Felix Sun 1 </li><li> Felix Sun 2 </li><li> Felix Sun 3 </li><li> Felix Sun 4 </li><li> Felix Sun 5 </li><li> Felix Sun 6 </li><li> Felix Sun 7 </li><li> Felix Sun 8 </li><li> Felix Sun 9 </li><li> Felix Sun 10 </li><li> Felix Sun 11 </li><li> Felix Sun 12 </li><li> Felix Sun 13 </li><li> Felix Sun 14 </li><li> Felix Sun 15 </li><li> Felix Sun 16 </li><li> Felix Sun 17 </li><li> Felix Sun 18 </li><li> Felix Sun 19 </li><li> Felix Sun 20 </li><li> Felix Sun 21 </li><li> Felix Sun 22 </li><li> Felix Sun 23 </li><li> Felix Sun 24 </li><li> Felix Sun 25 </li><li> Felix Sun 26 </li><li> Felix Sun 27 </li><li> Felix Sun 28 </li><li> Felix Sun 29 </li>
</ul>

please provide a working "tpl" example for beginner

Here is the compilation error.
[tjyang@hp1 test]$ gorazor tpl tpl.out
Processing dir: tpl tpl.out
Processing: tpl/helper/footer.gohtml --> /home/tjyang/gocode/src/test/tpl.out/helper/footer.go
Processing: tpl/helper/header.gohtml --> /home/tjyang/gocode/src/test/tpl.out/helper/header.go
Processing: tpl/helper/msg.gohtml --> /home/tjyang/gocode/src/test/tpl.out/helper/msg.go
Processing: tpl/home.gohtml --> /home/tjyang/gocode/src/test/tpl.out/home.go
Processing: tpl/layout/base.gohtml --> /home/tjyang/gocode/src/test/tpl.out/layout/base.go
[tjyang@hp1 test]$ cd tpl.out/
[tjyang@hp1 tpl.out]$ go build -x home.go
WORK=/tmp/go-build837451497
home.go:6:2: cannot find package "kp/models" in any of:
/usr/lib64/golang/src/pkg/kp/models (from $GOROOT)
/home/tjyang/gocode/src/kp/models (from $GOPATH)
home.go:7:2: cannot find package "tpl/helper" in any of:
/usr/lib64/golang/src/pkg/tpl/helper (from $GOROOT)
/home/tjyang/gocode/src/tpl/helper (from $GOPATH)
home.go:8:2: cannot find package "tpl/layout" in any of:
/usr/lib64/golang/src/pkg/tpl/layout (from $GOROOT)
/home/tjyang/gocode/src/tpl/layout (from $GOPATH)
[tjyang@hp1 tpl.out]$

Compiles error for struct constructor within template

@{
    import (
        "github.com/sunfmin/gorazortests/models"
    )
}

<body>
@Hello("Felix Sun", "h1", 30, &models.Author{"Van", 20},10)
</body>

generated:

package templates
import (
"github.com/sunfmin/gorazortests/models"
"github.com/sipin/gorazor/gorazor"
"bytes"

)
func Invokehello() string {
var _buffer bytes.Buffer
_buffer.WriteString("\n\n<body>\n")
_buffer.WriteString(gorazor.HTMLEscape(Hello("Felix Sun", "h1", 30, &models.Author{"Van", 20}
,10)))
_buffer.WriteString("\n</body>\n\n")


return _buffer.String()
}



compiles error:

Processing: templates/invokehello.gohtml --> /Users/sunfmin/gopkg/src/github.com/sunfmin/gorazortests/templates/invokehello.go
/Users/sunfmin/gopkg/src/github.com/sunfmin/gorazortests/templates/invokehello.go:11:94: missing ',' before newline in argument list

string return value

Is there a reason the return value on template functions is string instead of just bytes.Buffer? I understand it's more eye readable but it requires two transformations to write to ResponseWriter.

  1. The buffer is transformed to a string inside the template
return _buffer.String()
  1. Then the string is transformed to a []byte in a handler
    func index(w http.ResponseWriter, r *http.Request) {
        w.Write([]byte(views.Index())
    }

Wouldn't this be more efficient

views.Index().writeTo(w)

add the option that the gorazor can generate a private function.

The gorazor will change the file name to a first-letter upper function name, currently.
But I want that the gorazor put the file name direct to a function name,so I can generate a private function.I know this will break the exist client,so I suggest that we can add a option to do this.
I will try to add a pull request to do this.

Would be nice if gorazor can report line numbers of template files if UNMATCHED

Have no idea to find where quickly.

sunfmin@FelixMBPR ~/gopkg/src/github.com/theplant/qortex> gorazor ./templates/ ./templates/; go run main.go 
Processing dir: ./templates/ ./templates/
Processing: templates/users/UserHeader.gohtml --> /Users/sunfmin/gopkg/src/github.com/theplant/qortex/templates/users/UserHeader.go
panic: UNMATCHED

goroutine 1 [running]:
runtime.panic(0xf96c0, 0x2103bef70)
    /Users/sunfmin/go/src/pkg/runtime/panic.c:266 +0xb6
github.com/sipin/gorazor/gorazor.(*Parser).advanceUntil(0x21047e4b0, 0x210481044, 0x1, 0x1652f0, 0xd, ...)
    /Users/sunfmin/gopkg/src/github.com/sipin/gorazor/gorazor/parser.go:273 +0x24f
github.com/sipin/gorazor/gorazor.(*Parser).handleBLK(0x21047e4b0, 0x210481044, 0x1, 0x1652f0, 0xd, ...)
    /Users/sunfmin/gopkg/src/github.com/sipin/gorazor/gorazor/parser.go:407 +0x775
github.com/sipin/gorazor/gorazor.(*Parser).Run(0x21047e4b0, 0x0, 0x0)
    /Users/sunfmin/gopkg/src/github.com/sipin/gorazor/gorazor/parser.go:543 +0x29b
github.com/sipin/gorazor/gorazor.(*Parser).subParse(0x21047e460, 0x21048100b, 0x1, 0x166a50, 0xa, ...)
    /Users/sunfmin/gopkg/src/github.com/sipin/gorazor/gorazor/parser.go:290 +0x2ac
github.com/sipin/gorazor/gorazor.(*Parser).handleBLK(0x21047e460, 0x21048100b, 0x1, 0x166a50, 0xa, ...)
    /Users/sunfmin/gopkg/src/github.com/sipin/gorazor/gorazor/parser.go:432 +0x495
github.com/sipin/gorazor/gorazor.(*Parser).Run(0x21047e460, 0x0, 0x0)
    /Users/sunfmin/gopkg/src/github.com/sipin/gorazor/gorazor/parser.go:543 +0x29b
github.com/sipin/gorazor/gorazor.(*Parser).subParse(0x21047e410, 0x210481001, 0x1, 0x164890, 0xa, ...)
    /Users/sunfmin/gopkg/src/github.com/sipin/gorazor/gorazor/parser.go:290 +0x2ac
github.com/sipin/gorazor/gorazor.(*Parser).handleBLK(0x21047e410, 0x210481001, 0x1, 0x164890, 0xa, ...)
    /Users/sunfmin/gopkg/src/github.com/sipin/gorazor/gorazor/parser.go:432 +0x495
github.com/sipin/gorazor/gorazor.(*Parser).Run(0x21047e410, 0x0, 0x0)
    /Users/sunfmin/gopkg/src/github.com/sipin/gorazor/gorazor/parser.go:543 +0x29b
github.com/sipin/gorazor/gorazor.run(0x2104069f0, 0x21, 0x2104382a0, 0x210403e10, 0x0, ...)
    /Users/sunfmin/gopkg/src/github.com/sipin/gorazor/gorazor/gogen.go:322 +0x5bc
github.com/sipin/gorazor/gorazor.Generate(0x2104069f0, 0x21, 0x2104382a0, 0x43, 0xf96c0, ...)
    /Users/sunfmin/gopkg/src/github.com/sipin/gorazor/gorazor/gogen.go:348 +0x40
github.com/sipin/gorazor/gorazor.GenFile(0x2104069f0, 0x21, 0x21047d180, 0x51, 0x2104382a0, ...)
    /Users/sunfmin/gopkg/src/github.com/sipin/gorazor/gorazor/gogen.go:375 +0x43b
github.com/sipin/gorazor/gorazor.func·001(0x2104069f0, 0x21, 0x371930, 0x210403d20, 0x0, ...)
    /Users/sunfmin/gopkg/src/github.com/sipin/gorazor/gorazor/gogen.go:423 +0x21a
path/filepath.walk(0x2104069f0, 0x21, 0x371930, 0x210403d20, 0x2210511e00, ...)
    /Users/sunfmin/go/src/pkg/path/filepath/path.go:341 +0x72
path/filepath.walk(0x2103be570, 0xf, 0x371930, 0x210439dc0, 0x2210511e00, ...)
    /Users/sunfmin/go/src/pkg/path/filepath/path.go:359 +0x338
path/filepath.walk(0x7fff5fbffa58, 0xc, 0x371930, 0x2104393c0, 0x2210511e00, ...)
    /Users/sunfmin/go/src/pkg/path/filepath/path.go:359 +0x338
path/filepath.Walk(0x7fff5fbffa58, 0xc, 0x2210511e00, 0x3d, 0x0)
    /Users/sunfmin/go/src/pkg/path/filepath/path.go:380 +0xb7
github.com/sipin/gorazor/gorazor.GenFolder(0x7fff5fbffa58, 0xc, 0x7fff5fbffa65, 0xc, 0x2104382a0, ...)
    /Users/sunfmin/gopkg/src/github.com/sipin/gorazor/gorazor/gogen.go:431 +0x248
main.main()
    /Users/sunfmin/gopkg/src/github.com/sipin/gorazor/gorazor.go:38 +0x376
handlers/users/user_handlers.go:21:2: cannot find package "github.com/theplant/templates/users" in any of:
    /Users/sunfmin/go/src/pkg/github.com/theplant/templates/users (from $GOROOT)
    /Users/sunfmin/gopkg/src/github.com/theplant/templates/users (from $GOPATH)

GoRazor panic on a strange case

case reference: https://gist.github.com/Wuvist/7f22c2f3e2348e7b8479

Panic out put

panic: UNMATCHED!

goroutine 16 [running]:
runtime.panic(0x121f80, 0x2082d8460)
    /usr/local/go/src/pkg/runtime/panic.c:279 +0xf5
github.com/sipin/gorazor/gorazor.(*Parser).handleMKP(0x208398320, 0x2083702ac, 0x6, 0x197e90, 0xe, 0x11, 0xe, 0x1)
    /Users/wuvist/Dropbox/sipin/zfw_code/src/github.com/sipin/gorazor/gorazor/parser.go:354 +0x800
github.com/sipin/gorazor/gorazor.(*Parser).Run(0x208398320, 0x0, 0x0)
    /Users/wuvist/Dropbox/sipin/zfw_code/src/github.com/sipin/gorazor/gorazor/parser.go:541 +0x272
github.com/sipin/gorazor/gorazor.run(0x7fff5fbffb08, 0x3a, 0x2082e4c30, 0x0, 0x0, 0x0)
    /Users/wuvist/Dropbox/sipin/zfw_code/src/github.com/sipin/gorazor/gorazor/gogen.go:330 +0x620
github.com/sipin/gorazor/gorazor.Generate(0x7fff5fbffb08, 0x3a, 0x2082e4c30, 0x0, 0x0, 0x0, 0x0)
    /Users/wuvist/Dropbox/sipin/zfw_code/src/github.com/sipin/gorazor/gorazor/gogen.go:356 +0x64
github.com/sipin/gorazor/gorazor.GenFile(0x7fff5fbffb08, 0x3a, 0x7fff5fbffb43, 0x3a, 0x2082e4c30, 0x0, 0x0)
    /Users/wuvist/Dropbox/sipin/zfw_code/src/github.com/sipin/gorazor/gorazor/gogen.go:383 +0x502
main.main()
    /Users/wuvist/Dropbox/sipin/zfw_code/src/github.com/sipin/gorazor/gorazor.go:44 +0x637

goroutine 17 [runnable]:
runtime.MHeap_Scavenger()
    /usr/local/go/src/pkg/runtime/mheap.c:507
runtime.goexit()
    /usr/local/go/src/pkg/runtime/proc.c:1430

goroutine 18 [runnable]:
bgsweep()
    /usr/local/go/src/pkg/runtime/mgc0.c:1960
runtime.goexit()
    /usr/local/go/src/pkg/runtime/proc.c:1430

goroutine 19 [runnable]:
runfinq()
    /usr/local/go/src/pkg/runtime/mgc0.c:2586
runtime.goexit()
    /usr/local/go/src/pkg/runtime/proc.c:1430

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.