Skip to content

Commit

Permalink
Merge pull request #76 from webability-go/late-night
Browse files Browse the repository at this point in the history
patch v2.2.1
  • Loading branch information
metalwolf committed Sep 29, 2023
2 parents 9a8fdf5 + d7f48e5 commit c4bf63b
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
6 changes: 5 additions & 1 deletion v2/README.md
Expand Up @@ -14,7 +14,7 @@ For GO, the actual existing code includes:
- XLanguage: language dependent text tables, thread safe
- XTemplate: template system with meta language, thread safe cloning

Manuals are available on godoc.org [![GoDoc](https://godoc.org/github.com/webability-go/xcore?status.png)](https://godoc.org/github.com/webability-go/xcore)
Manuals are available on godoc.org [![GoDoc](https://godoc.org/github.com/webability-go/xcore/v2?status.png)](https://godoc.org/github.com/webability-go/xcore/v2)


TO DO, maybe:
Expand All @@ -31,6 +31,10 @@ Some improvements to check, later:
Version Changes Control
=======================

v2.2.1 - 2023-09-29
-----------------------
- Added the missing sub template .none for ?? meta language into XTemplate.

v2.2.0 - 2023-08-31
-----------------------
- Added the parameter status to xlanguage XML and function to get/set the parameter.
Expand Down
8 changes: 4 additions & 4 deletions v2/xcore.go
Expand Up @@ -24,7 +24,7 @@
//
// 1. Declare a new XCache with NewXCache() function:
//
// import "github.com/webability-go/xcore"
// import "github.com/webability-go/xcore/v2"
//
// // 50 items max
// var myfiles = xcore.NewXCache("myfiles", 50, 0)
Expand Down Expand Up @@ -237,7 +237,7 @@
//
// Example:
//
// import "github.com/webability-go/xcore"
// import "github.com/webability-go/xcore/v2"
//
// data := xcore.XDataset{}
// data["data1"] = "DATA1"
Expand Down Expand Up @@ -384,7 +384,7 @@
//
// import (
// "fmt"
// "github.com/webability-go/xcore"
// "github.com/webability-go/xcore/v2"
// )
//
// func main() {
Expand Down Expand Up @@ -879,7 +879,7 @@
package xcore

// VERSION is the used version nombre of the XCore library.
const VERSION = "2.2.0"
const VERSION = "2.2.1"

// LOG is the flag to activate logging on the library.
// if LOG is set to TRUE, LOG indicates to the XCore libraries to log a trace of functions called, with most important parameters.
Expand Down
8 changes: 8 additions & 0 deletions v2/xtemplate.go
Expand Up @@ -449,6 +449,14 @@ func (t *XTemplate) injector(datacol XDatasetCollectionDef, language *XLanguage)
datacol.Pop()
}
}
if value == nil || fmt.Sprint(value) == "" {
tmp := t.GetTemplate(subtemplateid + ".none")
if tmp != nil {
subt = tmp
}
substr := subt.injector(datacol, language)
injected = append(injected, substr)
}
case MetaDump:
if datacol != nil {
if v.Data == "dump" || v.Data == "list" {
Expand Down
21 changes: 21 additions & 0 deletions v2/xtemplate_test.go
Expand Up @@ -69,6 +69,27 @@ I love nothing<br />
// I love nothing<br />
}

func TestNewXTemplateEmptyCondition(t *testing.T) {
tmpl, _ := NewXTemplateFromString(`
TAGADA
??familyname??
[[familyname]]
Hello {{familyname}}<br />
[[]]
[[familyname.none]]
I don't know you<br />
[[]]
`)
// The creation of the data is obviously tedious here, in real life it should come from a JSON, a Database, etc
data := XDataset{
"clientname": "Fred",
}

fmt.Println(tmpl.Execute(&data))
// Output:
// I don't know you<br />
}

func TestNewXTemplateNilCollection(t *testing.T) {

tmpl, _ := NewXTemplateFromString(`
Expand Down

0 comments on commit c4bf63b

Please sign in to comment.