Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How iterate map? #51

Open
WarL0ckNet opened this issue Mar 31, 2023 · 1 comment
Open

How iterate map? #51

WarL0ckNet opened this issue Mar 31, 2023 · 1 comment

Comments

@WarL0ckNet
Copy link

WarL0ckNet commented Mar 31, 2023

In https://pugjs.org/language/iteration.html

ul
  each val, key in {1: 'one', 2: 'two', 3: 'three'}
    li= key + ': ' + val

How this write in your engine?

And how write one item from map? Example .arr[.key].field

arr{
  "one": {
     "field": 1
   },
   "two::{
      "field": 3
    }
}
@UnrealView
Copy link

Hello @WarL0ckNet, you can check the folder testdata/v2. There is a file about the iteration feature.
In iteration.pug:

ul
  each val, index in map[int]string{1:"one",2:"two",3:"three"}
    li= strconv.Itoa(index) + ": " + val

For how write one item from map? You can try something with un/buffered code feature:

-
    var mymap = map[string]string{"one":"","two":"","three":""}

doctype 5
html
    body
        p= mymap["one"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants