Questions tagged [shakespeare-text]

shakespeare-text is a Haskell library to generate text with interpolated variables

shakespeare-text is a Haskell library for text templates. It allows generating text from strings with embedded Haskell variables.

19 questions
12
votes
1 answer

What is the comment syntax in Yesod (hamlet) templates?

I just can not find how to comment line in hamlet template. Is there some syntax for comments? Like --

Some code should be ignored by template or something?

s9gf4ult
  • 862
  • 6
  • 20
5
votes
1 answer

How to read Yesod error messages effectively?

(newbie alert) Given the following error message, what's the quickest way to get to the source of the error: 08/Jul/2016:11:39:01 +0530 [Error#yesod-core] expected EPlain but got Nothing for: DerefBranch (DerefIdent (Ident "show")) (DerefString…
Saurabh Nanda
  • 6,373
  • 5
  • 31
  • 60
5
votes
2 answers

In yesod (haskell), how do I load a plain html-formatted file (not a hamlet) as a widget?

How do I load a plain html-formatted file (not a hamlet-formatted file) as a widget? In other words I'm looking for the html equivalent of: toWidget $(whamletFile "test.hamlet")
daj
  • 6,962
  • 9
  • 45
  • 79
3
votes
0 answers

Internationalizing Text in Yesod

I understand that the quasiquoter ihamlet will automatically call renderMessage for identifiers enclosed in _{...} (e.g. [ihamlet|_{MsgHello}|]). Is there a similar method for doing i18n with the "Shakespeare" Text quasiquoters (e.g. [st|...|])? I…
Ralph
  • 31,584
  • 38
  • 145
  • 282
3
votes
1 answer

Use Shakespeare-text and external file

How can I convert the below example to use an external file instead of the embedded lazy text quasi quotes? {-# LANGUAGE QuasiQuotes, OverloadedStrings #-} import Text.Shakespeare.Text import qualified Data.Text.Lazy.IO as TLIO import Data.Text…
Adam Gordon Bell
  • 3,083
  • 2
  • 26
  • 53
2
votes
1 answer

Where do shakespeare splices look for their files

I'm trying to get Shakespeare templates up and running; in particular Text.Hamlet. I have $(shamletFile "HTML/index.hamlet") (See notes) and when I compile the file I get an error telling me the file does not exist. So I have tried various…
John F. Miller
  • 26,961
  • 10
  • 71
  • 121
1
vote
0 answers

Haskell calling HTML using Shakespeare without Yesod widgets

Like Yesod, so diving in deep. Have a question: using Yesod I can call eg. data type App with Warp (warp 3000 App). How can I serve up HTML created using Shakespeare templates (like below). Got this from Michael Snoyman's book. {-# LANGUAGE…
Madderote
  • 1,107
  • 10
  • 19
1
vote
1 answer

can you load a widget with parameters in a hamlet file in yesod?

what is the best way to load html from a widget if your looping through a data set? i.e. in a hamlet file $forall Entity id val <- collection ^{myWidget (p1 val) (p2 val)}
Yunis
  • 23
  • 5
1
vote
2 answers

Lucius mixins cause "unexpected end of input", Can't find end of block

I'm trying to use mixins in Yesod's Lucius, but have run into a problem. Currently my 'center' mixin is the only one that seems to work, which also happens to be the only mixin without variable interpolation, although I'm not sure that is related to…
1
vote
2 answers

How to do IO in a Widget/Hamlet referenced by defaultLayout?

I'm new to Yesod and seem to be completely lost with Widgets, Handlers, Hamlets, WHamlets, and what have you! Here's what I'm trying to do: Every page on my site needs to have a navbar, which leads me to believe that the correct place for…
Saurabh Nanda
  • 6,373
  • 5
  • 31
  • 60
1
vote
2 answers

separate output list elements by delimiter in hamlet

If I have the code below, how do I get rid of the last comma in the output? Is there a way to see where in the loop I am and whether I am at the end? {-# LANGUAGE QuasiQuotes #-} import Text.Blaze.Html.Renderer.String (renderHtml) import…
akonsu
  • 28,824
  • 33
  • 119
  • 194
1
vote
1 answer

How to include a comment in an inline yesod javascript template

In the code toWidget [julius| $(function() { foo(); bar(); ) |] I want to comment out the call to bar. But toWidget [julius| $(function() { foo(); /* bar(); */ ) |] trips up the C preprocessor,…
Joachim Breitner
  • 25,395
  • 6
  • 78
  • 139
1
vote
1 answer

Ignoring leading whitespace in the "lazy-text" quasiquoter in Haskell Text.Shakespeare.Text

I am writing a Haskell command line program and using the lt quasiquoter ("lazy-text") from Text.Shakespeare.Text. In the Yesod book, it says that the hamlet quasiquoter ignores leading whitespace if the first non-whitespace character is a backslash…
Ralph
  • 31,584
  • 38
  • 145
  • 282
0
votes
0 answers

How to use arguments in Makefile in C

I am doing an assignment in C where I need to read in characters from a text file that contains the works of Shakespeare. My professor wants me to do the following: "Write a make file that can compile and run the C program you write. Specifically,…
0
votes
1 answer

What is the meaning of ^{...} in ".hamlet" files

In this ".hamlet" code I would like to know what is the meaning of ^{copyright} line $doctype 5 #{pageTitle} - My Site <link rel=stylesheet href=@{Stylesheet}> <body> <h1 .page-title>#{pageTitle} …</div> <div class="grid ai-start jc-space-between fw-wrap"> <div class="grid gs4 fw-wrap tags "> <a href="../../questions/tagged/haskell" class="post-tag grid--cell" title="show questions tagged 'haskell'" rel="tag">haskell</a> <a href="../../questions/tagged/yesod" class="post-tag grid--cell" title="show questions tagged 'yesod'" rel="tag">yesod</a> <a href="../../questions/tagged/shakespeare-text" class="post-tag grid--cell" title="show questions tagged 'shakespeare-text'" rel="tag">shakespeare-text</a> </div> <div class="started mt0"> <div class="s-user-card s-user-card"> <time class="s-user-card--time" datetime="asked Dec 02 '19 at 01:11">asked Dec 02 '19 at 01:11</time> <a href="../../users/11042609/chrometic" class="s-avatar s-avatar__32 s-user-card--avatar"> <img class="s-avatar--image" src="../../users/profiles/11042609.webp" data-jdenticon-width="32" data-jdenticon-height="32" data-jdenticon-value="chrometic" /> </a> <div class="s-user-card--info"> <a href="../../users/11042609/chrometic" class="s-user-card--link">chrometic</a> <ul class="s-user-card--awards"> <li class="s-user-card--rep" title="reputation score">81</li> <li class="s-award-bling s-award-bling__bronze" title="5 bronze badges">5</li> </ul> </div> </div> </div> </div> </div> </div> </div> <div class="s-pagination pager fr"> <div class="s-pagination--item is-selected">1</div> <a class="s-pagination--item" href="../../questions/tagged/shakespeare-text_page=2" rel="" title="Go to page 2">2</a> <a class="s-pagination--item" href="../../questions/tagged/shakespeare-text_page=2" rel="next" title="Go to page 2"> Next</a> </div> </div> </div> </div> </div> <script src="../../static/js/stack-icons.js"></script> <script src="../../static/js/fromnow.js"></script> </body> </html>