ace icon indicating copy to clipboard operation
ace copied to clipboard

Add support for square brackets

Open lloeki opened this issue 9 years ago • 4 comments

With Slim, using CSS-style square brackets is useful to disambiguate between content and empty attributes.

This is extremely useful in some situations such as using web components (e.g with Polymer).

Example in Slim ported from the Polymer tutorial:

body[unresolved]
  core-header-panel

  core-toolbar
    paper-tabs[id="tabs" selected="all" self-end]
      paper-tab[name="all"] All
      paper-tab[name="favorites"] Favorites

  .container[layout vertical center]

This code in Ace currently generates e.g acontainer[layout tag and center] as content.

Current, ugly workaround is to use empty equals to force Ace to recognise the attributes as such instead of outputting layout vertical center as content:

body unresolved=""
  core-header-panel

  core-toolbar
    paper-tabs id="tabs" selected="all" self-end=""
      paper-tab name="all" All
      paper-tab name="favorites" Favorites

  .container layout="" vertical="" center=""

lloeki avatar Nov 26 '14 11:11 lloeki

I see. Please give me time to think about this.

yosssi avatar Dec 19 '14 09:12 yosssi

@lloeki amber (https://github.com/eknkc/amber) does square brackets, maybe that would suit you more?

matejkramny avatar Feb 11 '15 00:02 matejkramny

@matejkramny amber looks interesting. But the square brackets seem mandatory: am I right? Not putting it down, btw. But I'd like to know.

@lloeki I've encountered the same problem u have with empty attributes. You dont actually need to specify the "" at the end. So the .container, for instance, can just simply be

.container layout= vertical= center=

Would be nice to have them be recognized as attributes still without the equal (tough request, yes I know!), but definitely still better than what you're doing now!

jf avatar Jun 18 '15 22:06 jf

@jf yes correct, square brackets are necessary for attributes.

Looking at it now, it may not be optimal since square brackets are valid xml characters. If you need an attribute that needs square brackets, it sort of gets confusing rather quickly. eg: a[href="yeah" [ng-click="doYeah()"]]

matejkramny avatar Jun 19 '15 07:06 matejkramny