Search code examples
htmlattributescomponentsaureliamultiline

multi-line in aurelia component html attribute property


This is a weird question about possibly embedding a string in an aurelia html file within the attribute tag but I would like to keep my tab and line formatting.

So, in my TS file I have the following:

this.queryDateStart += "type=EntityOne&dateQueryString=";

        this.queryDateStart += "" +
            "eOr( " +
                "eAnd( " +
                    "eAnd( facetName:isExcluded AND facetValue:No );" +
                    "dAnd( facetName:deadlineDate AND "+ dateRangePredicate  + ");" +
                    "); " +
                "dOr( " +
                    "(facetName:excludedUntilDate AND "+ dateRangePredicate  + ")" +
                ");" +
            ");"

And instead of having the following:

  <section as-element="ab-deadlines" data-query="${queryDateStart}"></section>

I would like to actually pass the literal string from above. But with the line spaces.

Would that break anything?

So for example ( going to try this today) - in my html file I would put:

 <section as-element="ab-deadlines"
                                                 data-query="
                                                 eOr(
                                                    eAnd(
                                                        eAnd( facetName:isExcluded AND facetValue:No );
                                                        dAnd( facetName:deadlineDate AND ${dateRangePredicate}  );
                                                    );
                                                    dOr(
                                                        (facetName:excludedUntilDate AND + ${dateRangePredicate}  )
                                                    );
                                                  );"></section>

Solution

  • About breaking: it shouldn't break anything. In the end, it's just normal HTML attribute, and as long as the spec allows it, it works in Aurelia, as Aurelia works directly, and plainly with HTML elements.

    You can see it yourself at this sandbox https://codesandbox.io/s/z20qx0q263