-
Notifications
You must be signed in to change notification settings - Fork 197
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
uncheckedHsx + customHsx #2010
uncheckedHsx + customHsx #2010
Conversation
Nah, sorry to say this is not yet great. It seems like the validation stuff works, but the rendering is just awful |
@mpscholten, WDYT of latest changes?
data HsxSettings = HsxSettings {
checkMarkup :: Bool,
additionalTagNames :: [Text],
additionalAttributeNames :: [Text]
} and then for example a custom hsx would look something like this: customHsx :: [Text] -> [Text] -> QuasiQuoter
customHsx additionalTagNames additionalAttributeNames = QuasiQuoter {
quoteExp = quoteHsxExpression (HsxSettings True additionalTagNames additionalAttributeNames),
quotePat = error "quotePat: not defined",
quoteDec = error "quoteDec: not defined",
quoteType = error "quoteType: not defined"
} Maybe also the newtype AdditionalTags = AdditionalTags [Text]
newtype AdditionalAttributes = AdditionalAttributes [Text] and then customHsx (AdditionalTags ["book", "title", "content"]) (AdditionalAttributes ["non-standard", "hrefplusplus"]) |
I went ahead with the whole thing and added All of what we talked about in #2009 should be solved now. Example declaration in a separate Helper module: module Application.Helper.CustomHsx where
import IHP.HSX.QQ (customHsx, AdditionalTags(..), AdditionalAttributes(..))
import Language.Haskell.TH.Quote
myHsx :: QuasiQuoter
myHsx = customHsx
(AdditionalTags ["test", "weird"])
(AdditionalAttributes ["strange", "attribute"])
|
Co-authored-by: Marc Scholten <[email protected]>
Co-authored-by: Marc Scholten <[email protected]>
Can now be tested like this: module Application.Helper.CustomHsx where
import IHP.Prelude
import IHP.HSX.QQ (customHsx)
import IHP.HSX.Parser
import Language.Haskell.TH.Quote
import qualified Data.Set as Set
myHsx :: QuasiQuoter
myHsx = customHsx
(HsxSettings
{ checkMarkup = True,
additionalTagNames = Set.fromList ["test", "weird"],
additionalAttributeNames = Set.fromList ["strange", "attribute"]
}
)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me now 👍 Thanks!
Thanks! Maybe worth adding a short section in the docs? |
@amitaibu Added some docs in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 👍
I think this works.Probably necessary with eyes of @mpscholten to verify the code is not too crazy. I had some AI help 😄
<hr>
and<br>
to not be explicitly closed, but disallows any other so we force users to close everything else. Makes the most sense I think