thedevsaddam / renderer Goto Github PK
View Code? Open in Web Editor NEWSimple, lightweight and faster response (JSON, JSONP, XML, YAML, HTML, File) rendering package for Go
License: MIT License
Simple, lightweight and faster response (JSON, JSONP, XML, YAML, HTML, File) rendering package for Go
License: MIT License
is this project still active?
while following your example,
I have few issues i described in comments. can you please advise?
package main
import (
"log"
"net/http"
"github.com/thedevsaddam/renderer"
)
var rnd *renderer.Render
func init() {
rnd = renderer.New(
renderer.Options{
ParseGlobPattern: "html/*.html",
},
)
}
func handler(w http.ResponseWriter, r *http.Request) {
# **i was able to declare a struct here.**
usr := struct {
Name string
Age int
}{"john doe", 30}
## passed in `usr` here
err := rnd.HTML(w, http.StatusOK, "indexPage", usr)
if err != nil {
log.Fatal(err)
}
}
func main() {
http.HandleFunc("/", handler)
log.Println("Listening port: 9000")
http.ListenAndServe(":9000", nil)
}
# html/index.html
{{define "indexPage"}}
<html>
{{template "header"}}
<body>
<h3>Index</h3>
**## this works**
<h1>Hello, {{ .Name }}</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit</p>
</body>
{{template "footer"}}
</html>
{{end}}
html/header.html
{{define "header"}}
<head>
<title>Header</title>
## this, no; not even `usr.Name`
<h1>Hello, {{ .Name }}</h1>
<h1>Header section</h1>
</head>
{{end}}
can you please advise on how do i pass values on extended template?
Right now when I try to use a function in Templates, the FuncMap doesn't load before it tries to parse the template.
So as a result, I get an undefined error for the function I'm trying to use.
It looks like there was some work to do this in:
https://github.com/thedevsaddam/renderer/blob/master/renderer.go#L550-L555
Is this something that'll be finished :)?
Also thanks for your work on this!
I want to create html text
for example:
data1 := <h1>hello</h1>
and save it to a variable->data1 and send it to template...but i can't
what can I do? noescape is removed from html/template
what should we do???
Could You Please Explain How To Send Response As JSON With Data From JSON File?
Currently in renderer_test.go
, verifying response headers still make use of the deprecated ResponseRecorder.HeaderMap
, while we can get the headers from ResponseRecorder.Header()
, which is recommended.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.