jeromegn / slang

Slim-inspired templating language for Crystal
MIT License
236 stars 30 forks source link

Crystal blocks in slang #21

Closed elorest closed 7 years ago

elorest commented 7 years ago
#form_helper.cr

def form_for
  String.build do |str|
  str << "<form>"
  str << yield
  str << "</form>
end

Theoretically this should work.

body
  == form_for do |f|
    input type="hidden" name="_csrf" value="EFnnkNC/rFDHQclQemvVVEzi1WVMMbItMUQBk6apbE"
    br
    input type="submit"

If whoever wrote the code evaling code in the first place could work on this that would be amazing. If not I'll take a stab at it in a couple weeks. I'm in the middle of writing form helpers for the Amber framework right now.

https://github.com/Amber-Crystal/amber

jeromegn commented 7 years ago

Good point.

Should also work without the double == if we keep following how slim does it.

jeromegn commented 7 years ago

@elorest I believe I have made this workable.

If you look at this branch comparison, it should work as expected: https://github.com/jeromegn/slang/compare/more-complex-block

Let me know if this seems to fulfill the requirement. If so, I'll merge in master, probably bump with a minor version.

elorest commented 7 years ago

Looks good. Also check out my Crystal Release helper for versioning and tagging. https://github.com/elorest/CRelease

jeromegn commented 7 years ago

Thanks, I did try CRelease. Worked well!

1.6.0 is now released with this fixed.