You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
below is a sample template func to explain my use case
{% func GenTestFunc() %}
func TestFunc(a int, b int) int {
var sum int
{% for i := 0; i < 10; i++ %}
sum += {%d i %}
{% endfor %}
return sum
}
{% endfunc %}
I'm getting:
func TestFunc(a int, b int) int {
var sum int
sum += 0
sum += 1
sum += 2
sum += 3
sum += 4
sum += 5
sum += 6
sum += 7
sum += 8
sum += 9
return sum
}
expect something like this:
func TestFunc(a int, b int) int {
var sum int
sum += 0
sum += 1
sum += 2
sum += 3
sum += 4
sum += 5
sum += 6
sum += 7
sum += 8
sum += 9
return sum
}
i tried {% stripspace %} and {% collapsespace %} but they are not sufficient
{% func %}, {% for %}, {% if %} and other tags, take string between as it is, to improve readability, these blocks can ignore first tab/space indent, or special tag to ignore them
also each the block, create a new line before them
i had to write this to get the intended output
{% func GenTestFunc() %}
func TestFunc(a int, b int) int {
var sum int{% for i := 0; i < 10; i++ %}
sum += {%d i %}{% endfor %}
return sum
}
{% endfunc %}
The text was updated successfully, but these errors were encountered:
Tag opening mark "{%-" strip tail blanks form previous text.
Tag ending mark "-%}" strip blanks to new line from next text.
Below code
{% func GenTestFunc() %}
func TestFunc(a int, b int) int {
var sum int
{%- for i := 0; i < 10; i++ -%}
sum += {%d i %}
{%- endfor %}
return sum
}
{% endfunc %}
outputs
func TestFunc(a int, b int) int {
var sum int
sum += 0
sum += 1
sum += 2
sum += 3
sum += 4
sum += 5
sum += 6
sum += 7
sum += 8
sum += 9
return sum
}
I am using QTPL for go code generation.
i see that it is intended for html template. But it can be very useful for all kind of text generation.
issue #27 does not cover my case
below is a sample template func to explain my use case
I'm getting:
expect something like this:
i tried
{% stripspace %}
and{% collapsespace %}
but they are not sufficient{% func %}
,{% for %}
,{% if %}
and other tags, take string between as it is, to improve readability, these blocks can ignore first tab/space indent, or special tag to ignore themi had to write this to get the intended output
The text was updated successfully, but these errors were encountered: