Comments (5)
not work, where I can see stupid example?
I need
for _, key := range gameByViewers {
fmt.Println(data[key]["name"])
}
in template
from pongo2.
Simply try {% if !mymap.Key %}Key does not exist{% else %}Does exist{% endif %}
. Does this work for you? Worked for me.
BTW, instead of using the !
operator, you can use the not
keyword as well (if not mymap.Key
).
Of course, it should work the other way around as well (not using the not
or !
-operator).
from pongo2.
Working example:
func main() {
result := pongo2.RenderTemplateString("{% if not mymap.Key %}Key does not exist{% else %}Does exist{% endif %}", pongo2.Context{"mymap": map[string]int{"Key": 1}})
fmt.Println(result)
}
or
func main() {
result := pongo2.RenderTemplateString("{% if mymap.Key %}Key does exist{% else %}Does not exist{% endif %}", pongo2.Context{"mymap": map[string]int{}})
fmt.Println(result)
}
Both works.
from pongo2.
Yes, this works fine. Found type in my code. Thanks for quick response!
from pongo2.
You're welcome!
from pongo2.
Related Issues (20)
- Cannot using template.Fromfile HOT 1
- Context key invalid HOT 1
- How to convert golang array to javascript array HOT 1
- Why this is no document about how to use it ?? HOT 8
- Struct field names in templates / contexts
- Data race in `pongo2.FromFile()` method HOT 5
- Potential security issue HOT 3
- date filter does not work as expected HOT 4
- Array in yml file as context is not supported
- Macro that invokes other macros does not work when imported HOT 1
- Not compatible with GCCGO 13.0.0 HOT 1
- How can pongo2 does not escape chars which except TokenSymbols?
- Bug: random order for `for` loop. HOT 2
- Include statement doesn't work inside for loop
- Returning only a partial block
- Potential BC break on master (missing var comparison)
- BC break between v4 and v6 (string/num adding/concatenating)
- question about split filter on new line
- need strings function HOT 1
- What tags deos pongo uses of declared structs struct?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pongo2.