2017-06-19 1 views
1
[whamlet| 

      <h2> Here's the ES results: 
      <h1> 
      <ul> 
       $forall EsHighlight high <- highlights re 
        <li> 
         <br> 
         #{toHtml high} 

     |] 

haute est quelque chose comme ceci:Yessod Whamlet rendu en HTML sans être échappé

"large <em>bamboo</em>, and a crotched stick. Throwing these down, he poked under a pile of rubbish, and brought out a rough block of wood, pierced through and through with a hole, which was immediately clapped on the top of the jar. Then planting the crotched stick upright about two yards distant, and making it sustain one end of the <em>bamboo</em>, he inserted the other end of the latter into the hole in the block: concluding these arrangements by placing an old calabash under the farther end of the <em>bamboo</em>." 

Le problème est que <em> n'est pas rendu en html mais la chaîne est restée. Donc, la page Web montre <em> lui-même. Que puis-je faire?

+0

Utilisez^{...} Au lieu de cela. – mb14

+0

@ mb14 thx mais cela ne fonctionne pas – osager

+0

pour utiliser^{..} vous avez besoin d'un widget au lieu d'une chaîne de caractères (ou texte). Vous devez transformer en quelque sorte 'high' pour être un widget (peut-être le générer en utilisant' [whamlet | .. |] '. – mb14

Répondre

2

En tant que protection contre les attaques XSS, le comportement par défaut de Hamlet (et de la bibliothèque blaze-html sous-jacente) est d'échapper toutes les entités HTML via la fonction toHtml. Si vous voulez éviter cette fuite, vous pouvez utiliser preEscapedToHtml. Notez que l'utilisation de cette fonction sur les données fournies par l'utilisateur est hautement dangereux.