Skip to content

Instantly share code, notes, and snippets.

@nqthqn
Last active July 15, 2018 15:22
Show Gist options
  • Save nqthqn/49a88371c9cc139ac61726703034e578 to your computer and use it in GitHub Desktop.
Save nqthqn/49a88371c9cc139ac61726703034e578 to your computer and use it in GitHub Desktop.
Name = "Hello"
Testing = ["1", "2", "3"]
package main
import (
"fmt"
"html/template"
"io/ioutil"
"os"
"github.com/BurntSushi/toml"
)
func main() {
var r map[string]interface{}
bs, err := ioutil.ReadFile("./config.toml")
if err != nil {
fmt.Println("config.toml issue:", err)
}
if toml.Unmarshal(bs, &r) != nil {
fmt.Println("Unmarshaling issue:", err)
}
t, err := template.ParseFiles("./view.html")
if err != nil {
fmt.Println("view.html template parse issue:", err)
}
f := os.Stdout
if t.Execute(f, r) != nil {
fmt.Println("template exectution issue:", err)
}
}
<h1>{{.Name}}</h1>
<ul>
{{range .Testing}}
<li>{{.}}</li>{{end}}
</ul>
@nqthqn
Copy link
Author

nqthqn commented Jul 15, 2018

Prints to standard out.

<h1>Hello</h1>
<ul>

  <li>1</li>
  <li>2</li>
  <li>3</li>
</ul>

Spec

  • Parse toml values into html template
  • Research how reference counting might work (in template rendering)
  • Determine final directory structure and configuration options
  • Write data structures to handle this
  • Write interpolated template to dist/
  • Watch files
  • Serve dist to localhost
  • Transpile sass
  • Create skeleton pattern browser
  • Render interpolated templates inside an iframe
  • Transform foo/[foo.scss, foo.html, foo.config] to dist/modules/foo/[foo_.html] where foo_.html has rendered foo.config values inside of it and is affected by the foo.scss module
  • Add web socket to listen for changes and dynamically reload

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment