[ANN] GWK - Version 0.6a Released

Skip to first unread message


Jun 5, 2013, 3:28:15 AM6/5/13
to golan...@googlegroups.com
- add viewengine, support temlate layout & partial template, you can find examples at ./test/views and ./demo/basic/views
- design new UI of demo project with bootstrap  
- add compressResponseWriter to compress response  
- route can use regexp to match request 
- bugs fix  and some new demo  

How to run demo

cd ./demo/basic  
go run main.go  

Mateusz Czapliński

Jun 5, 2013, 7:28:30 AM6/5/13
to golan...@googlegroups.com
Would Thou Fancy Issuing Textual Summary? (helps interpret details)


Jun 5, 2013, 10:02:10 PM6/5/13
to golan...@googlegroups.com
sorry for my bad English

1: view engine

add Temlate Func
eq //equal
eqs //format to string then compare
gt //greater than
le //less than
set //// set a map[string]interface{}
raw //unescaped html
selected //output "selected" or ""
checked // output "checked" or ""
nl2br // replace \n to <br/>
jsvar // convert data to javascript variable, like var name = {...}
import // import a layout file
incl // slice include

a example

{{set . "title" "title demo" }}
{{import "_layout.html" }}

{{define "head" }}
<script type="text/javascript">
div{padding: 10px;}

{{define "body" }}

<h1>hello gwk!</h1>

{{raw  "<!-- <script><style><html>  -->"}}

<lable for="selected">selected</lable>
<select id="selected">
<option value="" ></option>
<option value="selected" {{selected true}}>selected</option>
<lable for="notselected">not selected</lable>
<select id="notselected">
<option value="" ></option>
<option value="notselected" {{selected false}}>not selected</option>

<input id="checked" type="checkbox" {{checked true}}>checked</input>
<input id="notchecked" type="checkbox" {{checked false}}>not checked</input>

<li id="eq">eq 123 123 = {{eq 123 123}}</li>
<li id="eq">eqs "123" 123 = {{eqs "123" 123}}</li>
<li id="gt">gt 3.14 3 = {{gt 3.14 3}}</li>
<li id="le">le 1.1 2 = {{le 1.1 2}}</li>

<div>{{nl2br "a\nb\nc" }}</div>

<div id="settest-before">settest-before = {{.settest}}</div>
{{set . "settest" "true"}}
<div id="settest-after">settest-after = {{.settest}}</div>

{{partial "user.html" .user}}


{{define "script" }}

{{jsvar "user" .user}}


the output is 

redesign demo project, all demo & document will be integrated in this demo project, run main.go can see all changes

add compressResponseWriter to compress response  
// compressResponseWriter wrap gzip/deflate and ResponseWriter
type compressResponseWriter struct {
rw            http.ResponseWriter
writer        compresser
contentType   string
format        string
headerWritten bool

in previous version, gwk use CompressResult to compress http response, it's not flexible.

now, you can route with regexp like 

srv.RouteTable.Regexp("*", "^/user/?(?P<action>[[:alnum:]]+)?/?(?P<arg>[[:alnum:]]+)?/?").ToController(NewUserController())

it equals to 


Reply all
Reply to author
0 new messages