1

I have the following inside an HSX expression:

<a href={StudentsAction 
            (get #nameSort model) 
            (get #_currentFilter model) 
            Nothing 
            Nothing}>
    Last Name
</a>

With that, it's not clear which parameters of StudentsAction are getting which values. So I'd prefer something like this:

<a href={StudentsAction { 
            sortOrder = (get #nameSort model),
            currentFilter = (get #_currentFilter model),
            searchString = Nothing,
            pageIndex = Nothing } }>
    Last Name
</a>

However, that results in a parse error.

I can construct the record outside the HSX with something like this:

instance View IndexView where
    html IndexView { .. } = 

        let sortLastName = StudentsAction { 
                            sortOrder = (get #nameSort model),
                            currentFilter = (get #_currentFilter model),
                            searchString = Nothing,
                            pageIndex = Nothing }

        in 
        
        [hsx|
        <nav>
           ...
           <a href={sortLastName}>Last Name</a>

and that works fine, but I'd prefer to have it inline.

Is there a way to have the expression work inline? I'm guessing the inner braces are messing with the HSX parser? Perhaps they need to be escaped?

dharmatech
  • 8,979
  • 8
  • 42
  • 88
  • Is this materially different from [your previous question](https://stackoverflow.com/questions/68960202/overloadedlabels-in-ihp)? I mean, I'm fairly confident the answer is the same -- the existing parser isn't very good, and there's not much that can be done about that except wait for the project to replace it with GHC's parser (or do so yourself). – Daniel Wagner Aug 31 '21 at 20:12
  • ...in fact, the answer there even explicitly calls out `#` as one of the other things not supported. That makes me completely comfortable closing this as a dupe. – Daniel Wagner Aug 31 '21 at 20:14
  • @DanielWagner, `#` expressions do work in HSX. They're used throughout the tutorial. Note that Marc mentions a workaround that is used to get them to work. – dharmatech Sep 01 '21 at 01:16
  • @DanielWagner, This question is about record syntax in HSX specifically. The previous question was about support for `@` expressions. – dharmatech Sep 01 '21 at 01:17
  • @DanielWagner, I agree with you; the issue is likely due to the HSX parser. However, my question here is, is there a way to get them to work? I.e. perhaps by escaping characters, etc. – dharmatech Sep 01 '21 at 01:17

0 Answers0