Heist 템플릿 시스템을 사용하여 동적 링크를 만들려고합니다. 문제는 링크가 html로 해석되는 것이 아니라 텍스트로 나타나는 것입니다. Heist로 이런 다이나믹리스트를 만드는 특별한 방법이 있습니까?하스켈 스냅 프레임 워크 - 하이스와 동적 하이퍼 링크
링크가 구성되어 기능 : 웹 페이지의 텍스트
renderCategories :: Monad m => Db.Category -> I.Splice m
renderCategories (Db.Category catid catname catdesc) =
I.runChildrenWithText [ ("categoryId", T.concat $ ["<a href='http://localhost:8000/thread_home?cateid=", T.pack . show $ catid, "'>", T.pack . show $ catid, "</a>"])
, ("categoryName", catname)
, ("categoryDesc", catdesc)]
태그는 ": // localhost를? 8000/thread_home cateid = 1 '> 1 HTTP"로 나타납니다. 다음과 같이 그리고 소스를 보여줍니다
<a href='http://localhost:8000/thread_home?cateid=1'>1</a>
나는 그것을 실제 <를 인쇄해야 할 필요가 있음을 알> 그러나 나는 이것을 달성하는 방법을 잘 모르겠습니다. 현재 runChildrenWithText를 실행하여이 Heist 템플릿을 채우기 위해 runChildrenWith만으로 변경하면 텍스트 대신 스플 라이스가 필요하므로 '<'및 '>'이 (가) '&'(으)로 변환되지 않고 runChildrenWithText를 사용할 수 있기를 기대합니다. lt '및'& gt '와 같이 표시됩니다. 도움을 주시면 감사하겠습니다.
편집 내가 수동으로 사용하여 링크를 만들려고하고
:
Couldn't match type `X.Node' with `[X.Node]'
Expected type: I.Splice m
Actual type: heist-0.11.1:Heist.Types.HeistT m m X.Node
In the expression:
return
$ X.Element "a" [("href", "http://localhost")]
$ X.TextNode (T.pack $ show catid)
및
Couldn't match expected type `[X.Node]' with actual type `X.Node'
In the return type of a call of `X.TextNode'
In the second argument of `($)', namely
`X.TextNode (T.pack $ show catid)'
내가 할 : 나는 두 가지 오류가 발생하고 그러나
renderCategories :: Monad m => Db.Category -> I.Splice m
renderCategories (Db.Category catid catname catdesc) =
I.runChildrenWith [ ("categoryId", return $ X.Element "a"[("href", "http://localhost")] $ X.TextNode (T.pack $ show catid))]
을 별로는 안된다. 지금이 오류를 erirst 및 모든 도움을 주셔서 감사합니다. 모두 링크 및 일반 텍스트를 반환
작동 기능 :
renderCategories :: Monad m => Db.Category -> I.Splice m
renderCategories (Db.Category catid catname catdesc) =
I.runChildrenWith [("categoryId", return $ [X.Element "a" [("href", T.concat $ ["http://localhost:8000/thread_home?cateid=", T.pack $ show catid])] [X.TextNode (T.pack $ show catid)] ])
, ("categoryName", I.textSplice catname)
, ("categoryDesc", I.textSplice catdesc)]
첫 번째 수정 사항을 참조하십시오. – stickybynature
오, 죄송합니다. 나는 그 목록을 잊었다. 나는 대답을 업데이트 할 것이다. – mightybyte
splice가 [Node]를 반환해야하므로 편집 오류가 발생하지만 Node를 방금 반환했습니다. 또한 TextNode 부분에서 실수를 범했습니다. 그것도 목록이어야합니다. 답변을 업데이트했습니다. – mightybyte