From 637cb81340b6dc5380c259c1b84807510f82cef6 Mon Sep 17 00:00:00 2001 From: fall simply Date: Fri, 13 Mar 2020 00:13:52 -0500 Subject: [PATCH] update example --- README.md | 6 ++---- example/go.mod | 2 +- example/go.sum | 2 -- example/main.go | 20 ++++++++++++++------ 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 19170ba..b380460 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Bilit -[![Try it on Go Playground](https://img.shields.io/static/v1?label=Go%20Playground&message=Try%20It&color=00addc&style=for-the-badge&logo=go)]() +[![Try it on Go Playground](https://img.shields.io/static/v1?label=Go%20Playground&message=Try%20It&color=00addc&style=for-the-badge&logo=go)]() ![GitHub](https://img.shields.io/github/license/simplycodin/bilit?style=for-the-badge) Bilit (pronounced /ˈbilit/) is a bidirectional template library for golang. Inspired by Javascript's Template Literals and [Nunjucks](https://mozilla.github.io/nunjucks/templating.html) @@ -25,6 +25,4 @@ func main() { // map[City:Dallas from_state:TX name:John] } ``` -Open [Example Folder](./example) - -## Special Thanks +Open [Example Folder](./example) \ No newline at end of file diff --git a/example/go.mod b/example/go.mod index f53885a..7833d06 100644 --- a/example/go.mod +++ b/example/go.mod @@ -2,6 +2,6 @@ module github.com/SimplyCodin/bilit/example go 1.12 -require github.com/SimplyCodin/bilit v0.0.0-20190826050318-5ab9e1694da9 +require github.com/SimplyCodin/bilit v0.3.0 replace github.com/SimplyCodin/bilit => ../ diff --git a/example/go.sum b/example/go.sum index 8b48ad0..e69de29 100644 --- a/example/go.sum +++ b/example/go.sum @@ -1,2 +0,0 @@ -github.com/SimplyCodin/bilit v0.0.0-20190826050318-5ab9e1694da9 h1:ujak2uXt2JyPxtlDayZKvvaV+mOOrpzecmz1hez00Go= -github.com/SimplyCodin/bilit v0.0.0-20190826050318-5ab9e1694da9/go.mod h1:fUMSmukB2OQxFkWOZG9LpoYogb+IaBdQVQ2uKHzk2gA= diff --git a/example/main.go b/example/main.go index b54bfcc..2d127bf 100644 --- a/example/main.go +++ b/example/main.go @@ -1,17 +1,25 @@ package main import ( + //"encoding/json" + "fmt" + "github.com/SimplyCodin/bilit" ) func main() { - str := bilit.Populate("Hello, I'm {{name}} from {{City}}, {{from_state}}", bilit.Data{ + bilit.Debug = true + const template = "Hello, I'm {{name}} from ${City}, {{from_state}}" + var dataSrc = map[string]string{ "name": "John", "City": "Dallas", "from_state": "TX", - }) - print(str) - popstr := "Hello, I'm John from Dallas, TX" - test := bilit.Pull("Hello, I'm {{name}} from {{City}}, {{from_state}}", popstr) - print(test) + } + + var str = bilit.Populate(template, dataSrc) + fmt.Println(str, "end") + var data = bilit.Pull(template, str) + fmt.Println(data) + // bts, _ := json.Marshal(data) + // fmt.Println(string(bts)) }