
The data must be valid to avoid endless while loops.There is a confusing mixture of true Javascript (lines or blocks beginning with -) which are not very indent sensitive, and pug's pseudo Javascript which are indent sensitive.I added a helper function getMonth to reduce the verbosity to extract the month value that is buried deep in your data object.If the data is already sorted by the date, try: -Ĭonst calendar_events = [ I'll leave here this CodePen link, with the html version, because I think you guys can get the main idea of my question: The problem is that I get a duplicate for each entry in October, because I have to start the iteration on the first line: each event in calendar_events. var month = str.split(separator, 2).pop() // 10 I would like to make this without having to add an extra field, to select again a "month", which could bring bugs in case the selected month is not the same as on the date field (to be able to list the events, if does it makes sense)?įor now, I am on this step: each event in calendar_events Plain text does still use tag and string interpolation, but the first word on the line is not a Pug tag. On the backend I am just having a title field and a date field for each event. Pug provides four ways of getting plain text that is, any code or text content that should go, mostly unprocessed, directly into the rendered HTML. After listing the events for that month, I have to close that and start a new one for the next month. I am building an "Events List" in PugJS and I am going through each event and I would like to add a html element, like this, for each month.
