Package amber is an elegant templating engine for Go Programming Language. It is inspired from HAML and Jade. A tag is simply a word: is converted to It is possible to add ID and CLASS attributes to tags: are converted to Any arbitrary attribute name / value pair can be added this way: You can mix multiple attributes together gets converted to It is also possible to define these attributes within the block of a tag To add a doctype, use `!!!` or `doctype` keywords: or use `doctype` Available options: `5`, `default`, `xml`, `transitional`, `strict`, `frameset`, `1.1`, `basic`, `mobile` For single line tag text, you can just append the text after tag name: would yield For multi line tag text, or nested tags, use indentation: Input template data can be reached by key names directly. For example, assuming the template has been executed with following JSON data: It is possible to interpolate fields using `#{}` would print Attributes can have field names as well would print Amber can expand basic expressions. For example, it is possible to concatenate strings with + operator: Arithmetic expressions are also supported: Expressions can be used within attributes It is possible to define dynamic variables within templates, all variables must start with a $ character and can be assigned as in the following example: If you need to access the supplied data itself (i.e. the object containing Name, LastName etc fields.) you can use `$` variable For conditional blocks, it is possible to use `if <expression>` Again, it is possible to use arithmetic and boolean operators There is a special syntax for conditional attributes. Only block attributes can have conditions; This would yield a div with `hasfriends` class only if the `Friends > 0` condition holds. It is perfectly fine to use the same method for other types of attributes: It is possible to iterate over arrays and maps using `each`: would print It is also possible to iterate over values and indexes at the same time A template can include other templates using `include`: gets compiled to A template can inherit other templates. In order to inherit another template, an `extends` keyword should be used. Parent template can define several named blocks and child template can modify the blocks. License (The MIT License) Copyright (c) 2012 Ekin Koc <ekin@eknkc.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Ivy is an interpreter for an APL-like language. It is a plaything and a work in progress. Unlike APL, the input is ASCII and the results are exact (but see the next paragraph). It uses exact rational arithmetic so it can handle arbitrary precision. Values to be input may be integers (3, -1), rationals (1/3, -45/67) or floating point values (1e3, -1.5 (representing 1000 and -3/2)). Some functions such as sqrt are irrational. When ivy evaluates an irrational function, the result is stored in a high-precision floating-point number (default 256 bits of mantissa). Thus when using irrational functions, the values have high precision but are not exact. Unlike in most other languages, operators always have the same precedence and expressions are evaluated in right-associative order. That is, unary operators apply to everything to the right, and binary operators apply to the operand immediately to the left and to everything to the right. Thus, 3*4+5 is 27 (it groups as 3*(4+5)) and iota 3+2 is 1 2 3 4 5 while 3+iota 2 is 4 5. A vector is a single operand, so 1 2 3 + 3 + 3 4 5 is (1 2 3) + 3 + (3 4 5), or 7 9 11. As a special but important case, note that 1/3, with no intervening spaces, is a single rational number, not the expression 1 divided by 3. This can affect precedence: 3/6*4 is 2 while 3 / 6*4 is 1/8 since the spacing turns the / into a division operator. Use parentheses or spaces to disambiguate: 3/(6*4) or 3 /6*4. Ivy has complex numbers, which are constructed using the unary or binary j operator. As with rationals, the token 1j2 (the representation of 1+2i) is a single token. The individual parts can be rational, so 1/2j-3/2 is the complex number 0.5-1.5i and scans as a single value. Indexing uses [] notation: x[1], x[1; 2], and so on. Indexing by a vector selects multiple elements: x[1 2] creates a new item from x[1] and x[2]. An empty index slot is a shorthand for all the elements along that dimension, so x[] is equivalent to x, and x[;3] gives the third column of two-dimensional array x. Only a subset of APL's functionality is implemented, but all numerical operations are supported. Semicolons separate multiple statements on a line. Variables are alphanumeric and are assigned with the = operator. Assignment is an expression. After each successful expression evaluation, the result is stored in the variable called _ (underscore) so it can be used in the next expression. The APL operators, adapted from https://en.wikipedia.org/wiki/APL_syntax_and_symbols, and their correspondence are listed here. The correspondence is incomplete and inexact. Unary operators Binary operators Operators and axis indicator Type-converting operations The constants e (base of natural logarithms) and pi (π) are pre-defined to high precision, about 3000 decimal digits truncated according to the floating point precision setting. Strings are vectors of "chars", which are Unicode code points (not bytes). Syntactically, string literals are very similar to those in Go, with back-quoted raw strings and double-quoted interpreted strings. Unlike Go, single-quoted strings are equivalent to double-quoted, a nod to APL syntax. A string with a single char is just a singleton char value; all others are vectors. Thus “, "", and ” are empty vectors, `a`, "a", and 'a' are equivalent representations of a single char, and `ab`, `a` `b`, "ab", "a" "b", 'ab', and 'a' 'b' are equivalent representations of a two-char vector. Unlike in Go, a string in ivy comprises code points, not bytes; as such it can contain only valid Unicode values. Thus in ivy "\x80" is illegal, although it is a legal one-byte string in Go. Strings can be printed. If a vector contains only chars, it is printed without spaces between them. Chars have restricted operations. Printing, comparison, indexing and so on are legal but arithmetic is not, and chars cannot be converted automatically into other singleton values (ints, floats, and so on). The unary operators char and code enable transcoding between integer and char values. Users can define unary and binary operators, which then behave just like built-in operators. Both a unary and a binary operator may be defined for the same name. The syntax of a definition is the 'op' keyword, the operator and formal arguments, an equals sign, and then the body. The names of the operator and its arguments must be identifiers. For unary operators, write "op name arg"; for binary write "op leftarg name rightarg". The final expression in the body is the return value. Operators may have recursive definitions; see the paragraph about conditional execution for an example. The body may be a single line (possibly containing semicolons) on the same line as the 'op', or it can be multiple lines. For a multiline entry, there is a newline after the '=' and the definition ends at the first blank line (ignoring spaces). Conditional execution is done with the ":" binary conditional return operator, which is valid only within the code for a user-defined operator. The left operand must be a scalar. If it is non-zero, the right operand is returned as the value of the function. Otherwise, execution continues normally. The ":" operator has a lower precedence than any other operator; in effect it breaks the line into two separate expressions. Example: average of a vector (unary): Example: n largest entries in a vector (binary): Example: multiline operator definition (binary): Example: primes less than N (unary): Example: greatest common divisor (binary): On mobile platforms only, due to I/O restrictions, user-defined operators must be presented on a single line. Use semicolons to separate expressions: To declare an operator but not define it, omit the equals sign and what follows. Within a user-defined operator body, identifiers are local to the invocation if they are assigned before being read, and global if read before being written. To write to a global without reading it first, insert an unused read. To remove the definition of a unary or binary user-defined operator, Ivy accepts a number of special commands, introduced by a right paren at the beginning of the line. Most report the current value if a new value is not specified. For these commands, numbers are always read and printed base 10 and must be non-negative on input.
Amber is an elegant templating engine for Go Programming Language It is inspired from HAML and Jade A tag is simply a word: is converted to It is possible to add ID and CLASS attributes to tags: are converted to Any arbitrary attribute name / value pair can be added this way: You can mix multiple attributes together gets converted to It is also possible to define these attributes within the block of a tag To add a doctype, use `!!!` or `doctype` keywords: or use `doctype` Available options: `5`, `default`, `xml`, `transitional`, `strict`, `frameset`, `1.1`, `basic`, `mobile` For single line tag text, you can just append the text after tag name: would yield For multi line tag text, or nested tags, use indentation: Input template data can be reached by key names directly. For example, assuming the template has been executed with following JSON data: It is possible to interpolate fields using `#{}` would print Attributes can have field names as well would print Amber can expand basic expressions. For example, it is possible to concatenate strings with + operator: Arithmetic expressions are also supported: Expressions can be used within attributes It is possible to define dynamic variables within templates, all variables must start with a $ character and can be assigned as in the following example: If you need to access the supplied data itself (i.e. the object containing Name, LastName etc fields.) you can use `$` variable For conditional blocks, it is possible to use `if <expression>` Again, it is possible to use arithmetic and boolean operators There is a special syntax for conditional attributes. Only block attributes can have conditions; This would yield a div with `hasfriends` class only if the `Friends > 0` condition holds. It is perfectly fine to use the same method for other types of attributes: It is possible to iterate over arrays and maps using `each`: would print It is also possible to iterate over values and indexes at the same time A template can include other templates using `include`: gets compiled to A template can inherit other templates. In order to inherit another template, an `extends` keyword should be used. Parent template can define several named blocks and child template can modify the blocks. License (The MIT License) Copyright (c) 2012 Ekin Koc <ekin@eknkc.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Package window is the easiest way to open a window and render graphics. The window package effectively provides an easy cross-platform way to create and configure a window, as well as manipulate it and receive user input from it efficiently. The window package lays the groundwork for developing applications that are truly cross-platform (i.e. desktop and mobile applications) using nearly the exact same API in the future. As such, the window package is mostly just an abstraction layer for GLFW on desktop operating systems. If you truly need features not found in this package then you might be best using GLFW directly if you intend to just write desktop applications. Some features are not supported by this package intentionally, like multiple windows because mobile devices don't have them. The goal of the window package is not to provide a one solution fits all, it is instead to abstract away the tedious parts of writing cross-device applications in the future. The window package is also extremely simple to use:
Package window is the easiest way to open a window and render graphics. The window package effectively provides an easy cross-platform way to create and configure a window, as well as manipulate it and receive user input from it efficiently. The window package lays the groundwork for developing applications that are truly cross-platform (i.e. desktop and mobile applications) using nearly the exact same API in the future. As such, the window package is mostly just an abstraction layer for GLFW on desktop operating systems. If you truly need features not found in this package then you might be best using GLFW directly if you intend to just write desktop applications. Some features are not supported by this package intentionally, like multiple windows because mobile devices don't have them. The goal of the window package is not to provide a one solution fits all, it is instead to abstract away the tedious parts of writing cross-device applications in the future. The window package is also extremely simple to use:
Package amber is an elegant templating engine for Go Programming Language. It is inspired from HAML and Jade. A tag is simply a word: is converted to It is possible to add ID and CLASS attributes to tags: are converted to Any arbitrary attribute name / value pair can be added this way: You can mix multiple attributes together gets converted to It is also possible to define these attributes within the block of a tag To add a doctype, use `!!!` or `doctype` keywords: or use `doctype` Available options: `5`, `default`, `xml`, `transitional`, `strict`, `frameset`, `1.1`, `basic`, `mobile` For single line tag text, you can just append the text after tag name: would yield For multi line tag text, or nested tags, use indentation: Input template data can be reached by key names directly. For example, assuming the template has been executed with following JSON data: It is possible to interpolate fields using `#{}` would print Attributes can have field names as well would print Amber can expand basic expressions. For example, it is possible to concatenate strings with + operator: Arithmetic expressions are also supported: Expressions can be used within attributes It is possible to define dynamic variables within templates, all variables must start with a $ character and can be assigned as in the following example: If you need to access the supplied data itself (i.e. the object containing Name, LastName etc fields.) you can use `$` variable For conditional blocks, it is possible to use `if <expression>` Again, it is possible to use arithmetic and boolean operators There is a special syntax for conditional attributes. Only block attributes can have conditions; This would yield a div with `hasfriends` class only if the `Friends > 0` condition holds. It is perfectly fine to use the same method for other types of attributes: It is possible to iterate over arrays and maps using `each`: would print It is also possible to iterate over values and indexes at the same time A template can include other templates using `include`: gets compiled to A template can inherit other templates. In order to inherit another template, an `extends` keyword should be used. Parent template can define several named blocks and child template can modify the blocks. License (The MIT License) Copyright (c) 2012 Ekin Koc <ekin@eknkc.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Amber is an elegant templating engine for Go Programming Language It is inspired from HAML and Jade A tag is simply a word: is converted to It is possible to add ID and CLASS attributes to tags: are converted to Any arbitrary attribute name / value pair can be added this way: You can mix multiple attributes together gets converted to It is also possible to define these attributes within the block of a tag To add a doctype, use `!!!` or `doctype` keywords: or use `doctype` Available options: `5`, `default`, `xml`, `transitional`, `strict`, `frameset`, `1.1`, `basic`, `mobile` For single line tag text, you can just append the text after tag name: would yield For multi line tag text, or nested tags, use indentation: Input template data can be reached by key names directly. For example, assuming the template has been executed with following JSON data: It is possible to interpolate fields using `#{}` would print Attributes can have field names as well would print Amber can expand basic expressions. For example, it is possible to concatenate strings with + operator: Arithmetic expressions are also supported: Expressions can be used within attributes It is possible to define dynamic variables within templates, all variables must start with a $ character and can be assigned as in the following example: If you need to access the supplied data itself (i.e. the object containing Name, LastName etc fields.) you can use `$` variable For conditional blocks, it is possible to use `if <expression>` Again, it is possible to use arithmetic and boolean operators There is a special syntax for conditional attributes. Only block attributes can have conditions; This would yield a div with `hasfriends` class only if the `Friends > 0` condition holds. It is perfectly fine to use the same method for other types of attributes: It is possible to iterate over arrays and maps using `each`: would print It is also possible to iterate over values and indexes at the same time A template can include other templates using `include`: gets compiled to A template can inherit other templates. In order to inherit another template, an `extends` keyword should be used. Parent template can define several named blocks and child template can modify the blocks. License (The MIT License) Copyright (c) 2012 Ekin Koc <ekin@eknkc.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Package amber is an elegant templating engine for Go Programming Language. It is inspired from HAML and Jade. A tag is simply a word: is converted to It is possible to add ID and CLASS attributes to tags: are converted to Any arbitrary attribute name / value pair can be added this way: You can mix multiple attributes together gets converted to It is also possible to define these attributes within the block of a tag To add a doctype, use `!!!` or `doctype` keywords: or use `doctype` Available options: `5`, `default`, `xml`, `transitional`, `strict`, `frameset`, `1.1`, `basic`, `mobile` For single line tag text, you can just append the text after tag name: would yield For multi line tag text, or nested tags, use indentation: Input template data can be reached by key names directly. For example, assuming the template has been executed with following JSON data: It is possible to interpolate fields using `#{}` would print Attributes can have field names as well would print Amber can expand basic expressions. For example, it is possible to concatenate strings with + operator: Arithmetic expressions are also supported: Expressions can be used within attributes It is possible to define dynamic variables within templates, all variables must start with a $ character and can be assigned as in the following example: If you need to access the supplied data itself (i.e. the object containing Name, LastName etc fields.) you can use `$` variable For conditional blocks, it is possible to use `if <expression>` Again, it is possible to use arithmetic and boolean operators There is a special syntax for conditional attributes. Only block attributes can have conditions; This would yield a div with `hasfriends` class only if the `Friends > 0` condition holds. It is perfectly fine to use the same method for other types of attributes: It is possible to iterate over arrays and maps using `each`: would print It is also possible to iterate over values and indexes at the same time A template can include other templates using `include`: gets compiled to A template can inherit other templates. In order to inherit another template, an `extends` keyword should be used. Parent template can define several named blocks and child template can modify the blocks. License (The MIT License) Copyright (c) 2012 Ekin Koc <ekin@eknkc.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Amber is an elegant templating engine for Go Programming Language It is inspired from HAML and Jade A tag is simply a word: is converted to It is possible to add ID and CLASS attributes to tags: are converted to Any arbitrary attribute name / value pair can be added this way: You can mix multiple attributes together gets converted to It is also possible to define these attributes within the block of a tag To add a doctype, use `!!!` or `doctype` keywords: or use `doctype` Available options: `5`, `default`, `xml`, `transitional`, `strict`, `frameset`, `1.1`, `basic`, `mobile` For single line tag text, you can just append the text after tag name: would yield For multi line tag text, or nested tags, use indentation: Input template data can be reached by key names directly. For example, assuming the template has been executed with following JSON data: It is possible to interpolate fields using `#{}` would print Attributes can have field names as well would print Amber can expand basic expressions. For example, it is possible to concatenate strings with + operator: Arithmetic expressions are also supported: Expressions can be used within attributes It is possible to define dynamic variables within templates, all variables must start with a $ character and can be assigned as in the following example: If you need to access the supplied data itself (i.e. the object containing Name, LastName etc fields.) you can use `$` variable For conditional blocks, it is possible to use `if <expression>` Again, it is possible to use arithmetic and boolean operators There is a special syntax for conditional attributes. Only block attributes can have conditions; This would yield a div with `hasfriends` class only if the `Friends > 0` condition holds. It is perfectly fine to use the same method for other types of attributes: It is possible to iterate over arrays and maps using `each`: would print It is also possible to iterate over values and indexes at the same time A template can include other templates using `include`: gets compiled to A template can inherit other templates. In order to inherit another template, an `extends` keyword should be used. Parent template can define several named blocks and child template can modify the blocks. License (The MIT License) Copyright (c) 2012 Ekin Koc <ekin@eknkc.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Amber is an elegant templating engine for Go Programming Language It is inspired from HAML and Jade A tag is simply a word: is converted to It is possible to add ID and CLASS attributes to tags: are converted to Any arbitrary attribute name / value pair can be added this way: You can mix multiple attributes together gets converted to It is also possible to define these attributes within the block of a tag To add a doctype, use `!!!` or `doctype` keywords: or use `doctype` Available options: `5`, `default`, `xml`, `transitional`, `strict`, `frameset`, `1.1`, `basic`, `mobile` For single line tag text, you can just append the text after tag name: would yield For multi line tag text, or nested tags, use indentation: Input template data can be reached by key names directly. For example, assuming the template has been executed with following JSON data: It is possible to interpolate fields using `#{}` would print Attributes can have field names as well would print Amber can expand basic expressions. For example, it is possible to concatenate strings with + operator: Arithmetic expressions are also supported: Expressions can be used within attributes It is possible to define dynamic variables within templates, all variables must start with a $ character and can be assigned as in the following example: If you need to access the supplied data itself (i.e. the object containing Name, LastName etc fields.) you can use `$` variable For conditional blocks, it is possible to use `if <expression>` Again, it is possible to use arithmetic and boolean operators There is a special syntax for conditional attributes. Only block attributes can have conditions; This would yield a div with `hasfriends` class only if the `Friends > 0` condition holds. It is perfectly fine to use the same method for other types of attributes: It is possible to iterate over arrays and maps using `each`: would print It is also possible to iterate over values and indexes at the same time A template can include other templates using `include`: gets compiled to A template can inherit other templates. In order to inherit another template, an `extends` keyword should be used. Parent template can define several named blocks and child template can modify the blocks. License (The MIT License) Copyright (c) 2012 Ekin Koc <ekin@eknkc.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Package amber is an elegant templating engine for Go Programming Language. It is inspired from HAML and Jade. A tag is simply a word: is converted to It is possible to add ID and CLASS attributes to tags: are converted to Any arbitrary attribute name / value pair can be added this way: You can mix multiple attributes together gets converted to It is also possible to define these attributes within the block of a tag To add a doctype, use `!!!` or `doctype` keywords: or use `doctype` Available options: `5`, `default`, `xml`, `transitional`, `strict`, `frameset`, `1.1`, `basic`, `mobile` For single line tag text, you can just append the text after tag name: would yield For multi line tag text, or nested tags, use indentation: Input template data can be reached by key names directly. For example, assuming the template has been executed with following JSON data: It is possible to interpolate fields using `#{}` would print Attributes can have field names as well would print Amber can expand basic expressions. For example, it is possible to concatenate strings with + operator: Arithmetic expressions are also supported: Expressions can be used within attributes It is possible to define dynamic variables within templates, all variables must start with a $ character and can be assigned as in the following example: If you need to access the supplied data itself (i.e. the object containing Name, LastName etc fields.) you can use `$` variable For conditional blocks, it is possible to use `if <expression>` Again, it is possible to use arithmetic and boolean operators There is a special syntax for conditional attributes. Only block attributes can have conditions; This would yield a div with `hasfriends` class only if the `Friends > 0` condition holds. It is perfectly fine to use the same method for other types of attributes: It is possible to iterate over arrays and maps using `each`: would print It is also possible to iterate over values and indexes at the same time A template can include other templates using `include`: gets compiled to A template can inherit other templates. In order to inherit another template, an `extends` keyword should be used. Parent template can define several named blocks and child template can modify the blocks. License (The MIT License) Copyright (c) 2012 Ekin Koc <ekin@eknkc.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.