k0kubun / hamlit

High Performance Haml Implementation
https://rubygems.org/gems/hamlit
Other
981 stars 59 forks source link

Feature request :) - for / else #159

Closed dux closed 4 years ago

dux commented 4 years ago

The same it is implemented in Svelte https://github.com/sveltejs/svelte/issues/90

It would be nice, if we would be able to write

- for el in @model.children
  %p= el.name
- else
 .danger List is empty

and not as now

- children = @model.children
- if children.first
  - for el in children
    %p= el.name
- else
 .danger List is empty

I suggest not to play smart, just if for produces blank? - true, use else block.

Added to https://github.com/haml/haml/issues/1037 as well.

WaKeMaTTa commented 4 years ago

I think feature requested they need to be approved first in https://github.com/haml/haml

dux commented 4 years ago

ok, but why? This does not brake compatibility.

WaKeMaTTa commented 4 years ago

Because Hamlit only implements the features of haml.

Le lun. 27 juil. 2020 à 12:57, Dino Reić notifications@github.com a écrit :

ok, but why? This does not brake compatibility.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/k0kubun/hamlit/issues/159#issuecomment-664323430, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2KLEIAJ5FH7DTYNRTVGJDR5VMQ3ANCNFSM4PIUGJ7Q .

k0kubun commented 4 years ago

@WaKeMaTTa is right. One of the reasons is that Hamlit shares the same parser as Haml, and not using the exact same parser would increase maintenance cost of Hamlit. So at least syntax-level features like this should be proposed and implemented in Haml to avoid diverging the parser part.

Thanks for filing https://github.com/haml/haml/issues/1037! Please feel free to reopen this issue once it's merged.