当前位置: 首页>>代码示例>>Golang>>正文


Golang gorazor.HTMLEscape函数代码示例

本文整理汇总了Golang中github.com/sipin/gorazor/gorazor.HTMLEscape函数的典型用法代码示例。如果您正苦于以下问题:Golang HTMLEscape函数的具体用法?Golang HTMLEscape怎么用?Golang HTMLEscape使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了HTMLEscape函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Index

func Index(users []*models.User, total int, limit int, offset int) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n\n<h2 class=\"sub-header\">用户总数:")
	_buffer.WriteString(gorazor.HTMLEscape(gorazor.Itoa(total)))
	_buffer.WriteString("</h2>\n<div class=\"table-responsive\">\n	<table class=\"table table-striped\">\n		<thead>\n			<tr>\n				<th>名字</th>\n				<th>电邮</th>\n				<th>编辑</th>\n			</tr>\n		</thead>\n		<tbody>\n			")
	for _, u := range users {

		_buffer.WriteString("<tr>\n				<td>")
		_buffer.WriteString(gorazor.HTMLEscape(u.Name))
		_buffer.WriteString("</td>\n				<td>")
		_buffer.WriteString(gorazor.HTMLEscape(u.Email))
		_buffer.WriteString("</td>\n				<td><a href=\"/admin/user/edit?id=")
		_buffer.WriteString(gorazor.HTMLEscape(u.ID.Hex()))
		_buffer.WriteString("\">编辑</a></td>\n			</tr>")

	}
	_buffer.WriteString("\n		</tbody>\n	</table>\n</div>")

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

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

		_buffer.WriteString("用户管理")

		return _buffer.String()
	}

	return layout.Base(_buffer.String(), title(), js())
}
开发者ID:fanliao,项目名称:gorazor,代码行数:33,代码来源:index.go

示例2: Init

func Init(data ConfigData) string {
	var _buffer bytes.Buffer

	var upcaseModule = strings.ToUpper(data.Module)

	_buffer.WriteString("\npackage config\n\nimport (\n\t\"log\"\n\t\"os\"\n\t\"strings\"\n)\n\n// this is configured from env variables\nvar (\n\tEnv                 string\n\tWebDir              string\n\t")
	if data.Database == "mysql" {

		_buffer.WriteString((MysqlVars()))

	}
	_buffer.WriteString("\n)\n\nfunc init() {\n\tEnv = envOrPanic(\"")
	_buffer.WriteString(gorazor.HTMLEscape((upcaseModule)))
	_buffer.WriteString("_ENV\", false)\n\tWebDir = envOrPanic(\"")
	_buffer.WriteString(gorazor.HTMLEscape((upcaseModule)))
	_buffer.WriteString("_WEBDIR\", false)\n\t")
	if data.Database == "mysql" {

		_buffer.WriteString((MysqlAssigns(upcaseModule)))

	}
	_buffer.WriteString("\n}\n\nfunc envOrPanic(key string, allowEmpty bool) (r string) {\n\tr = os.Getenv(key)\n\tif r == \"\" && !allowEmpty {\n\t\tpanic(\"env \" + key + \" is not set\")\n\t}\n\tlogValue := r\n\tif strings.Contains(logValue, \"PASSWORD\") || strings.Contains(logValue, \"SECRET\") {\n\t\tlogValue = \"<HIDDEN>\"\n\t}\n\tlog.Printf(\"Configure: %s = %s\\n\", key, logValue)\n\treturn\n}")

	return _buffer.String()
}
开发者ID:sunfmin,项目名称:hyperboot,代码行数:25,代码来源:Init.go

示例3: Add

func Add(content string, err string) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n\n<link rel=\"stylesheet\" href=\"/css/bootstrap-datetimepicker.css\">\n\n<style>\n.row {\n	margin-top: 10px;\n}\n</style>\n\n<h2>日程登记</h2>\n\n<div class=\"container-fluid\">\n	<form method=\"POST\" action=\"\">\n	<div class=\"row\" >\n		<p class=\"bg-danger\">")
	_buffer.WriteString(gorazor.HTMLEscape(err))
	_buffer.WriteString("</p>\n	</div>\n\n	<div class=\"row\">\n	内容:\n	<input type='text' class=\"form-control\" name=\"content\" value=\"")
	_buffer.WriteString(gorazor.HTMLEscape(content))
	_buffer.WriteString("\"/>\n	</div>\n	\n	<div class=\"row\">\n	开始时间:\n	<input type='text' class=\"datetimepicker form-control\" name=\"startTime\"/>\n	</div>\n	\n	<div class=\"row\">\n	结束时间:\n	<input type='text' class=\"datetimepicker form-control\" name=\"endTime\"/>\n	</div>\n\n	<div class=\"row\">\n	日程指派:\n	<select name=\"appoint\">\n		<option>cheney</option>\n		<option>wuvist</option>\n	</select>\n	</div>\n	\n	<div class=\"row\">\n	<input style=\"float:right\" type=\"submit\" value=\"保存\" class=\"btn btn-primary\"/>\n	</div>\n	</form>\n</div>")

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

		_buffer.WriteString("管理后台 - 添加日程")

		return _buffer.String()
	}

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

		_buffer.WriteString("<script src=\"/js/moment.js\"></script>")

		_buffer.WriteString("<script src=\"/js/bootstrap-datetimepicker.js\"></script>")

		_buffer.WriteString("<script type=\"text/javascript\">\n	$(function () {\n		$(\".datetimepicker\").datetimepicker({\n			format: \"YYYY-MM-DD HH:mm\",\n			defaultDate: \"2014-05-01 00:00\",\n		})\n	});\n</script>")

		return _buffer.String()
	}

	return layout.Base(_buffer.String(), title(), js())
}
开发者ID:fanliao,项目名称:gorazor,代码行数:30,代码来源:add.go

示例4: tplImage

func tplImage(conf Image) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n<img src=\"")
	_buffer.WriteString(gorazor.HTMLEscape(conf.Src))
	_buffer.WriteString("\" style=\"")
	_buffer.WriteString(gorazor.HTMLEscape(conf.getStyle()))
	_buffer.WriteString("\"/>")

	return _buffer.String()
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:10,代码来源:tplImage.go

示例5: PackageJson

func PackageJson(data ReactData) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n{\n  \"name\": \"")
	_buffer.WriteString(gorazor.HTMLEscape((data.Module)))
	_buffer.WriteString("\",\n  \"version\": \"0.0.1\",\n  \"description\": \"")
	_buffer.WriteString(gorazor.HTMLEscape((data.Module)))
	_buffer.WriteString("\",\n  \"main\": \"app.js\",\n  \"directories\": {\n    \"test\": \"test\"\n  },\n  \"dependencies\": {\n    \"moment\": \"^2.8.4\",\n    \"react\": \"^0.12.2\",\n    \"webpack\": \"^1.4.15\",\n    \"jsx-loader\": \"^0.12.2\",\n    \"css-loader\": \"^0.9.0\",\n    \"style-loader\": \"^0.8.2\",\n    \"less\": \"^2.2.0\",\n    \"less-loader\": \"^2.0.0\",\n    \"extract-text-webpack-plugin\": \"^0.3.6\",\n    \"file-loader\": \"^0.8.1\",\n    \"bootstrap\": \"^3.3.1\",\n    \"url-loader\": \"^0.5.5\",\n    \"jquery\": \"^2.1.3\"\n  },\n  \"devDependencies\": {},\n  \"scripts\": {},\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git://yourdomain.com/yourrepository.git\"\n  },\n  \"keywords\": [\n    \"ui\",\n    \"widget\"\n  ],\n  \"author\": {\n    \"name\": \"Your Name\"\n  },\n  \"license\": \"MIT\",\n  \"bugs\": {\n    \"url\": \"https://yourdomain.com/yourrepository/issues\"\n  },\n  \"homepage\": \"https://yourdomain.com/yourrepository\"\n}")

	return _buffer.String()
}
开发者ID:sunfmin,项目名称:hyperboot,代码行数:10,代码来源:PackageJson.go

示例6: tplHorizontalDescription

func tplHorizontalDescription(conf HorizontalDescription) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n<dl class=\"dl-horizontal\">\n    <dt>")
	_buffer.WriteString(gorazor.HTMLEscape(conf.Key))
	_buffer.WriteString("</dt>\n    <dd>")
	_buffer.WriteString(gorazor.HTMLEscape(conf.Value))
	_buffer.WriteString("</dd>\n</dl>")

	return _buffer.String()
}
开发者ID:keysonZZZ,项目名称:kmg,代码行数:10,代码来源:tplHorizontalDescription.go

示例7: Header

func Header(u *User) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n\t<meta charset=\"UTF-8\">\n\t<title>")
	_buffer.WriteString(gorazor.HTMLEscape(u.Name))
	_buffer.WriteString(" ")
	_buffer.WriteString(gorazor.HTMLEscape(u.Email))
	_buffer.WriteString("</title>\n</head>\n<body>\n<div>Page Header</div>")

	return _buffer.String()
}
开发者ID:vycb,项目名称:gorazortpl,代码行数:10,代码来源:header.go

示例8: Index

func Index(data WebData) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n<!doctype html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"utf-8\">\n    <title>Main</title>\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n    <link rel=\"stylesheet\" href=\"/")
	_buffer.WriteString(gorazor.HTMLEscape((data.Module)))
	_buffer.WriteString("/assets/main.css\">\n  </head>\n  <body>\n    <section id=\"react\"></section>\n    <script src=\"/")
	_buffer.WriteString(gorazor.HTMLEscape((data.Module)))
	_buffer.WriteString("/assets/main.js\"></script>\n  </body>\n</html>")

	return _buffer.String()
}
开发者ID:sunfmin,项目名称:hyperboot,代码行数:10,代码来源:Index.go

示例9: Routes

func Routes(data WebData) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\npackage web\n\nimport (\n\t\"")
	_buffer.WriteString(gorazor.HTMLEscape(data.ConfigPkg))
	_buffer.WriteString("\"\n\t\"github.com/codegangsta/negroni\"\n\t\"github.com/gorilla/mux\"\n\t\"github.com/phyber/negroni-gzip/gzip\"\n\t\"net/http\"\n\t\"os\"\n\t\"path\"\n)\n\nfunc Routes() (n *negroni.Negroni) {\n\n\trouter := mux.NewRouter()\n\n\t// router.HandleFunc(\"/p/{articleId}.html\", Article)\n\n\tn = negroni.New()\n\tn.Use(gzip.Gzip(gzip.DefaultCompression))\n\n\tif config.Env != \"production\" {\n\t\tn.Use(negroni.NewRecovery())\n\t} else {\n\t\tn.Use(NewProductionRecovery())\n\t}\n\n\twebdir := path.Clean(config.WebDir)\n\tif _, err := os.Stat(webdir); err != nil {\n\t\tpanic(err)\n\t\treturn\n\t}\n\n\tstatic := &negroni.Static{\n\t\tDir:       http.Dir(webdir),\n\t\tPrefix:    \"/")
	_buffer.WriteString(gorazor.HTMLEscape((data.Module)))
	_buffer.WriteString("\",\n\t\tIndexFile: \"index.html\",\n\t}\n\n\tn.Use(static)\n\tn.Use(negroni.NewLogger())\n\tn.UseHandler(router)\n\treturn\n}")

	return _buffer.String()
}
开发者ID:sunfmin,项目名称:hyperboot,代码行数:10,代码来源:Routes.go

示例10: Main

func Main(data WebData) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\npackage main\n\nimport (\n\t\"")
	_buffer.WriteString(gorazor.HTMLEscape(data.WebPkg))
	_buffer.WriteString("\"\n\t\"")
	_buffer.WriteString(gorazor.HTMLEscape(data.HttpImplPkg))
	_buffer.WriteString("\"\n\t\"log\"\n\t\"net/http\"\n)\n\nfunc main() {\n\n\t")
	_buffer.WriteString(gorazor.HTMLEscape((data.Module)))
	_buffer.WriteString("apihttpimpl.AddToMux(\"/api\", http.DefaultServeMux)\n\n\thttp.Handle(\"/\", web.Routes())\n\n\tlog.Println(\"Starting Server at 9000.\")\n\terr := http.ListenAndServe(\":9000\", nil)\n\tif err != nil {\n\t\tlog.Fatal(\"ListenAndServe: \", err)\n\t}\n}")

	return _buffer.String()
}
开发者ID:sunfmin,项目名称:hyperboot,代码行数:12,代码来源:Main.go

示例11: Base

func Base(body string, title string) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n<!DOCTYPE html>\n<html>\n<head>\n	<meta charset=\"utf-8\" />\n    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n	<link rel=\"stylesheet\" href=\"/css/bootstrap.min.css\">\n	<link rel=\"stylesheet\" href=\"/css/dashboard.css\">\n    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->\n    <!--[if lt IE 9]>\n      <script src=\"https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js\"></script>\n      <script src=\"https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js\"></script>\n    <![endif]-->\n	<title>")
	_buffer.WriteString(gorazor.HTMLEscape(title))
	_buffer.WriteString("</title>\n</head>\n<body>\n    <div class=\"navbar navbar-inverse navbar-fixed-top\" role=\"navigation\">\n      <div class=\"container-fluid\">\n        <div class=\"navbar-header\">\n          <button type=\"button\" class=\"navbar-toggle\" data-toggle=\"collapse\" data-target=\".navbar-collapse\">\n            <span class=\"sr-only\">Toggle navigation</span>\n            <span class=\"icon-bar\"></span>\n            <span class=\"icon-bar\"></span>\n            <span class=\"icon-bar\"></span>\n          </button>\n          <a class=\"navbar-brand\" href=\"#\">广东省政法委信息化平台</a>\n        </div>\n        <div class=\"navbar-collapse collapse\">\n          <ul class=\"nav navbar-nav navbar-right\">\n            <li><a href=\"/admin/setting\">设置</a></li>\n            <li><a href=\"/admin/help\">帮助</a></li>\n            <li><a href=\"/admin/logout\">退出</a></li>\n          </ul>\n          <form class=\"navbar-form navbar-right\">\n            <input type=\"text\" class=\"form-control\" placeholder=\"搜索...\">\n          </form>\n        </div>\n      </div>\n    </div>\n\n    <div class=\"container-fluid\">\n      <div class=\"row\">\n        <div class=\"col-sm-3 col-md-2 sidebar\">\n			")
	_buffer.WriteString((helper.Menu()))
	_buffer.WriteString("\n        </div>\n        <div class=\"col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main\">\n          ")
	_buffer.WriteString(gorazor.HTMLEscape(body))
	_buffer.WriteString("\n        </div>\n      </div>\n    </div>\n	<script src=\"/js/jquery.min.js\"></script>\n	<script src=\"/js/bootstrap.min.js\"></script>\n  </body>\n</html>")

	return _buffer.String()
}
开发者ID:fanliao,项目名称:gorazor,代码行数:12,代码来源:base.go

示例12: Layout

func Layout(body string, title string, side string) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"utf-8\" />")
	_buffer.WriteString(gorazor.HTMLEscape(title))
	_buffer.WriteString("\n</head>\n<body>\n<div>")
	_buffer.WriteString(gorazor.HTMLEscape(body))
	_buffer.WriteString("</div>\n<div>")
	_buffer.WriteString(gorazor.HTMLEscape(side))
	_buffer.WriteString("</div>\n</body>\n</html>")

	return _buffer.String()
}
开发者ID:Zheaoli,项目名称:gorazor,代码行数:12,代码来源:layout.go

示例13: Simple

func Simple(u *model.User) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\n<html>\n    <body>\n        <h1>")
	_buffer.WriteString(gorazor.HTMLEscape(u.FirstName))
	_buffer.WriteString("</h1>\n\n        <p>Here's a list of your favorite colors:</p>\n        <ul>\n        ")
	for _, colorName := range u.FavoriteColors {

		_buffer.WriteString("<li>")
		_buffer.WriteString(gorazor.HTMLEscape(colorName))
		_buffer.WriteString("</li>")
	}

	_buffer.WriteString("\n        </ul>\n    </body>\n</html>")

	return _buffer.String()
}
开发者ID:SlinSo,项目名称:goTemplateBenchmark,代码行数:16,代码来源:simple.go

示例14: Bug8

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

	return _buffer.String()
}
开发者ID:Zheaoli,项目名称:gorazor,代码行数:8,代码来源:bug8.go

示例15: Db

func Db(data DbData) string {
	var _buffer bytes.Buffer
	_buffer.WriteString("\npackage db\n\nimport (\n\t\"")
	_buffer.WriteString(gorazor.HTMLEscape(data.ConfigPkg))
	_buffer.WriteString("\"\n\t\"fmt\"\n\t_ \"github.com/go-sql-driver/mysql\"\n\t\"github.com/jinzhu/gorm\"\n)\n\nvar DB gorm.DB\nvar AllModels = []interface{}{\n\t&User{},\n}\n\nfunc init() {\n\thost := config.MySQLHost\n\tdatabase := config.MySQLDatabase\n\n\tvar err error\n\tconnect := fmt.Sprintf(\"root:%[email protected](%s:%s)/%s?parseTime=true\", config.MySQLRootPassword, host, config.MySQLPort, database)\n\t// fmt.Println(connect)\n\tDB, err = gorm.Open(\"mysql\", connect)\n\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Error when connect database: '%v'\", err))\n\t}\n\n\tDB.LogMode(config.Env == \"development\")\n\n\tmodels := AllModels\n\n\tfor _, m := range models {\n\t\terr = DB.AutoMigrate(m).Error\n\t\tif err != nil {\n\t\t\tpanic(fmt.Sprintf(\"Error when migrate: '%v'\", err))\n\t\t}\n\t}\n\n}")

	return _buffer.String()
}
开发者ID:sunfmin,项目名称:hyperboot,代码行数:8,代码来源:Db.go


注:本文中的github.com/sipin/gorazor/gorazor.HTMLEscape函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。