Clean up
This commit is contained in:
@@ -21,13 +21,13 @@ A new string with all placeholders replaced by their corresponding values from
|
||||
the dictionary. If a key is missing in the dictionary, the placeholder is
|
||||
replaces with an empty string.
|
||||
*/
|
||||
mustache_string :: proc(fmt: string, v: any ) -> string {
|
||||
mustache_string :: proc(fmt: string, v: any , end_block: string = "") -> string {
|
||||
r : strings.Reader
|
||||
strings.reader_init(&r, fmt)
|
||||
return mustache(&r, v, "")
|
||||
return mustache(&r, v, end_block)
|
||||
}
|
||||
|
||||
mustache_reader :: proc(r: ^strings.Reader, v: any, end_block: string ) -> string {
|
||||
mustache_reader :: proc(r: ^strings.Reader, v: any, end_block: string = "" ) -> string {
|
||||
/*
|
||||
template works as a state machine, it manipulates `b` (returned string)
|
||||
and `key` (placeholder string), according to the states. No error
|
||||
@@ -82,6 +82,8 @@ mustache_reader :: proc(r: ^strings.Reader, v: any, end_block: string ) -> strin
|
||||
}
|
||||
case '#':
|
||||
strings.write_string(&b, section(r, v, skey[1:]) )
|
||||
case '^':
|
||||
strings.write_string(&b, section(r, v, skey[1:], true) )
|
||||
case:
|
||||
strings.write_string(&b, decode_string(v, skey) )
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user