> try converting the following imperative script even by hand:

interesting challenge!

this is my solution using nimib's `nbKaraxCode` (karax without boilerplate):
    
    
    nbKaraxCode:
      const
        helloId = "helloId"
        inputId = "inputId"
      var
        hello = "welcome to the hello program"
        name = ""
      karaxHtml:
        p(id=helloId):
          text hello
        label:
          text "enter a name or the word 'exit':"
        input(id = inputId, `type` = "text"):
          text name
        button:
          text "Enter"
          proc onClick() =
            name = $getVNodeById(inputId).getInputText
            hello = "Hello, " & name
    
    
    Run

you can see it in action here: 
<https://pietroppeter.github.io/nblog/drafts/hello_name.html>

it did not require any particular reasoning, it is a pretty straightforward 
translation. it could possibly benefit from some [karax 
widgets](https://forum.nim-lang.org/postActivity.xml) to simplify even further. 
also I guess I could avoid the button, but I do not know how to do it.

it does not seem too different from the original but I guess state is indeed 
managed somewhere, would be interested in hearing your thoughts about it :)

Reply via email to