Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Injecting custom splices [digestive-functors-heist] #134

Open
cimmanon opened this issue Oct 2, 2016 · 0 comments
Open

Injecting custom splices [digestive-functors-heist] #134

cimmanon opened this issue Oct 2, 2016 · 0 comments

Comments

@cimmanon
Copy link
Contributor

cimmanon commented Oct 2, 2016

I have a number of forms that have immutable data that I would like to present to the user, but the only way I can do so with digestive-functors-heist (without binding additional splices into the template myself) is with some sort of text input element (dfInputText, dfInputTextArea, etc.). This ends up making a rather unattractive form and requires disabling the input element to reinforce the fact that it is immutable.

My first attempt at working around this was to create a copy of digestiveSplices that calls the original function in addition to my custom splice. This worked fine for the top level form, but it doesn't propagate down into sub views (dfSubView) or lists (dfInputList) because those splices still call the original digestiveSplices and bindDigestiveSplices functions. I ended up hacking the digestiveSplices function to add my custom splice for rendering the plain text contents. This seemed fine at first, but now I find myself wanting more custom splices... and going back and hacking the base library each time I need something new is less than desirable.

I would like to propose creating alternate versions of the digestiveSplices and bindDigestiveSplices functions that accepts a (View Text -> Splices (Splice m)) as its first argument.

digestiveSplices' :: MonadIO m => (View Text -> Splices (Splice m)) -> View Text -> Splices (Splice m)
digestiveSplices' splices view = do
    "dfInput"            ## dfInput view
    "dfInputList"        ## dfInputList' splices view
    "dfInputText"        ## dfInputText view
    "dfInputTextArea"    ## dfInputTextArea view
    "dfInputPassword"    ## dfInputPassword view
    "dfInputHidden"      ## dfInputHidden view
    "dfInputSelect"      ## dfInputSelect view
    "dfInputSelectGroup" ## dfInputSelectGroup view
    "dfInputRadio"       ## dfInputRadio view
    "dfInputCheckbox"    ## dfInputCheckbox view
    "dfInputFile"        ## dfInputFile view
    "dfInputSubmit"      ## dfInputSubmit view
    "dfLabel"            ## dfLabel view
    "dfForm"             ## dfForm view
    "dfErrorList"        ## dfErrorList view
    "dfChildErrorList"   ## dfChildErrorList view
    "dfSubView"          ## dfSubView' splices view
    "dfIfChildErrors"    ## dfIfChildErrors view
    splices view

I've done a quick modification of the Interpreted splices: https://gist.github.com/cimmanon/f40e706dcf2d3370c09380edded9ddce

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant