Open mpscholten opened 3 years ago
Some initial work has been done in https://github.com/digitallyinduced/ihp/pull/1174
would it be in any way, like this:
indexAction = [text|
action #{pluralName}Action = do
#{(if paginationEnabled } #{then} ( #{modelVariablePlural}Q, pagination) <- query @#{model} |> paginate
#{modelVariablePlural} <- #{modelVariablePlural}Q |> fetch
#{else} #{modelVariablePlural} <- query @#{model} |> fetch
#{)} render IndexView { .. }
|]
Yes, like that 👍 (The if else syntax would be a bit different, like #{if paginationEnabled then ... else ..}
)
thanks, I am on it then 👍
Cool! Let us know in case you need any help
Sure 👍
I went as far as using the local copy of the development server to check the generated code but i had no luck embedding Haskell code inside. As to the following snippet, I had to import NeatInterpolation and it worked; is there any doc that's available other than the one provided above which i could read to better understand what to do?
newAction = [text|
action New${singularName}Action = do
let $modelVariablePlural = newRecord
render NewView { .. }
|]
If you compare the old PHP-based code generators with the newer Haskell-based one's , the PHP-based code gen's have much more readable code.
One low hanging fruit is to replace the normal haskell strings with https://hackage.haskell.org/package/neat-interpolation-0.5.1.2/docs/NeatInterpolation.html
Basically replacing code like this:
With this: