pzavolinsky / elmx

A tiny precompiler that takes an Elm program with embedded HTML and desugars the HTML into elm-html syntax. Elmx is to Elm what React's JSX is to Javascript
MIT License
353 stars 11 forks source link

Allow attribute list interpolation #1

Closed prozacchiwawa closed 8 years ago

prozacchiwawa commented 8 years ago

An experiment to allow

<input {:self.attributes} id={self.idstem} value={inputContent self}/>

to generate

Html.input (List.concatMap identity [[Html.Attributes.attribute "id" self.idstem, Html.Attributes.attribute "value" (inputContent self)], self.attributes]) []

What do you think?

pzavolinsky commented 8 years ago

Awesome, @prozacchiwawa !

Merged the PR and published new versions of elmx and the language-elmx atom plugin (in atom you need to View -> Reload after updating for the new version to work).

I only did some minor changes to replace the concatMap identity with ++ and updated the README.md

Thanks for the contribution!

Cheers

prozacchiwawa commented 8 years ago

Thanks for writing elmx at all ... it's nice.

Thanks for taking a look at my pull request. Would you be interested in a change that makes dots in tag names override the use of Html as a prefix in tags and Html.Attributes in attributes? My initial use case is elm-svg like this:

import Svg as S exposing (..)

-- ...

let clickable = if m.enabled then [onClick address (Click x)] else [] in
<div {styles}>
    <S.svg baseProfile="tiny" version="1.2" height="120" width="1120">
        <S.circle {:clickable} cx={toString (60 + (250 * x))} cy="60"

r="50" fill="rgba(0,0,0,0)"></S.circle>

On Mon, Feb 8, 2016 at 12:50 PM, Patricio Zavolinsky < notifications@github.com> wrote:

Awesome, @prozacchiwawa https://github.com/prozacchiwawa !

Merged the PR and published new versions of elmx and the language-elmx atom plugin (in atom you need to View -> Reload after updating for the new version to work).

I only did some minor changes https://github.com/pzavolinsky/elmx/commit/bed67e8cc0bb4746eca6569575b12f8e3ca3a7de to replace the concatMap identity with ++ and updated the README.md

Thanks for the contribution!

Cheers

— Reply to this email directly or view it on GitHub https://github.com/pzavolinsky/elmx/pull/1#issuecomment-181530953.

pzavolinsky commented 8 years ago

Sure, that would be great (and should be just a small change in the generator).

Haven't tried elm-svg yet but if you want to PR that change I'll give it a try.

Cheers

prozacchiwawa commented 8 years ago

Ok. Thanks.

On Tue, Feb 9, 2016 at 1:18 AM, Patricio Zavolinsky < notifications@github.com> wrote:

Sure, that would be great (and should be just a small change in the generator).

Haven't tried elm-svg yet but if you want to PR that change I'll give it a try.

Cheers

— Reply to this email directly or view it on GitHub https://github.com/pzavolinsky/elmx/pull/1#issuecomment-181774207.