Open yamachu opened 4 years ago
https://gist.github.com/catatsuy/e627aaf118fbe001f2e7c665fda48146#template%E3%81%AE%E4%BD%BF%E3%81%84%E6%96%B9
template.FuncMap はテンプレート内で独自の関数を呼び出す際に必要で、移植元の参考実装が使用している場合、実装を合わせるために利用される`
template.FuncMap
FuncMapでやってるのは
url_for
src/templates/base_bottom.html:<script type="text/javascript" src="{{ url_for "/js/jquery.min.js" }}"></script> src/templates/base_bottom.html:<script type="text/javascript" src="{{ url_for "/js/bootstrap.min.js" }}"></script> src/templates/base_top.html:<link rel="stylesheet" href="{{ url_for "/css/bootstrap.min.css" }}"> src/templates/base_top.html:<link rel="stylesheet" href="{{ url_for "/css/bootstrap-responsive.min.css" }}"> src/templates/base_top.html:<link rel="stylesheet" href="{{ url_for "/" }}"> src/templates/base_top.html:<li><a href="{{ url_for "/" }}">Home</a></li> src/templates/base_top.html:<li><a href="{{ url_for "/mypage" }}">MyPage</a></li> src/templates/base_top.html:<li><a href="{{ url_for "/signin" }}">SignIn</a></li> src/templates/index.html: <a href="{{ url_for "/memo/" }}{{ .Id }}">{{ first_line .Content }}</a> by {{ .Username }} ({{ .CreatedAt }}) src/templates/memo.html:<a id="older" href="{{ url_for "/memo/" }}{{ .Older.Id }}">< older memo</a> src/templates/memo.html:<a id="newer" href="{{ url_for "/memo/" }}{{ .Newer.Id }}">newer memo ></a> src/templates/mypage.html:<form action="{{ url_for "/memo" }}" method="post"> src/templates/mypage.html: <a href="{{ url_for "/memo/" }}{{ .Id }}">{{ first_line .Content }}</a> by {{ .Username }} ({{ .CreatedAt }}) src/templates/signin.html:<form action="{{ url_for "/signin" }}" method="post">
firsrt_line
src/templates/index.html: <a href="{{ url_for "/memo/" }}{{ .Id }}">{{ first_line .Content }}</a> by {{ .Username }} ({{ .CreatedAt }}) src/templates/mypage.html: <a href="{{ url_for "/memo/" }}{{ .Id }}">{{ first_line .Content }}</a> by {{ .Username }} ({{ .CreatedAt }})
get_token
src/templates/base_top.html: <input type="hidden" name="sid" value="{{ get_token .Session }}"> src/templates/mypage.html: <input type="hidden" name="sid" value="{{ get_token .Session }}">
gen_markdown
src/templates/memo.html:{{ gen_markdown .Memo.Content }}
first_line
https://gist.github.com/catatsuy/e627aaf118fbe001f2e7c665fda48146#template%E3%81%AE%E4%BD%BF%E3%81%84%E6%96%B9
FuncMapでやってるのは
url_for
firsrt_line
get_token
gen_markdown