Hi there!

I've been interested in the Elm Architecture for a while and I've been 
given permisson from my team to work on a side project to test it out and 
see if we can start to implement Elm step by step. We are looking to create 
a more high-performance UI, but it's important that our rendered HTML and 
JS works with our existing stack of technologies, one of them being e.g. 
Bootstrap.

*Problem: *I currently have a very specific problem, but will try to avoid 
the XY problem and abstract it to a more general problem which could be 
useful for more people. I have the following HTML snippet:

<button type="button" class="..." data-toggle="dropdown">


Which I want to translate to elm (snippet):


[ button [type' "button, class "...", dataToggle "dropdown"] []


with the latter part of course not doing anything. I know there are some 
efforts to port bootstrap components 
<https://github.com/circuithub/elm-bootstrap-dropdown/blob/master/src/Bootstrap/Dropdown.elm>
 to elm and that I could emulate the same behaviour with an Elm Dropdown. But 
for compatibility purposes I wish I could just use special Attributes (e.g. 
"data-toggle", not yet implemented in Elm) to use bootstrap accordingly.


*Take on solution:* I tried to look in the elm-source code and write a 
*dataToggle 
Attribute *myself, but that did not work. *Question:* Is there a way to 
just pass attributes to elm and have it compile it to js to include such 
special Attributes? (Also for example when using React or other frameworks)

import Html exposing (Html, button, Attribute)
import Html.App as Html
import Html.Attributes exposing (..)
import Json.Encode as Json

...

[ button [class "example", dataToggle "dropdown"] []

...

stringProperty : String -> String -> Attribute msg
stringProperty name string =
  property name (Json.string string)

dataToggle : String -> Attribute msg
dataToggle value =
   stringProperty "data-toggle" value


Thanks in advance!

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to