Hamlet html-angle-brackets change

This commit is contained in:
Michael Snoyman 2010-07-04 01:28:15 +03:00
parent fcfd1559ca
commit 2289400d7a
7 changed files with 41 additions and 47 deletions

View File

@ -132,12 +132,12 @@ fieldsToTable = mapM_ go
wrapWidget (fiInput fi) $ \w -> [$hamlet|
%tr
%td
%label!for=$string.fiIdent.fi$ $fiLabel.fi$
.tooltip $fiTooltip.fi$
%label!for=$fiIdent.fi$ $<fiLabel.fi>$
.tooltip $<fiTooltip.fi>$
%td
^w^
$maybe fiErrors.fi err
%td.errors $err$
%td.errors $<err>$
|]
class IsForm a where
@ -213,7 +213,7 @@ stringField = FieldProfile
{ fpParse = Right
, fpRender = id
, fpHamlet = \name val isReq -> [$hamlet|
%input#$name$!name=$name$!type=text!:isReq:required!value=$val$
%input#$<name>$!name=$<name>$!type=text!:isReq:required!value=$<val>$
|]
, fpWidget = \_name -> return ()
}
@ -227,7 +227,7 @@ intField = FieldProfile
{ fpParse = maybe (Left "Invalid integer") Right . readMayI
, fpRender = showI
, fpHamlet = \name val isReq -> [$hamlet|
%input#$name$!name=$name$!type=number!:isReq:required!value=$val$
%input#$<name>$!name=$<name>$!type=number!:isReq:required!value=$<val>$
|]
, fpWidget = \_name -> return ()
}
@ -250,7 +250,7 @@ doubleField = FieldProfile
{ fpParse = maybe (Left "Invalid number") Right . readMay
, fpRender = show
, fpHamlet = \name val isReq -> [$hamlet|
%input#$name$!name=$name$!type=number!:isReq:required!value=$val$
%input#$<name>$!name=$<name>$!type=number!:isReq:required!value=$<val>$
|]
, fpWidget = \_name -> return ()
}
@ -265,13 +265,13 @@ dayField = FieldProfile
. readMay
, fpRender = show
, fpHamlet = \name val isReq -> [$hamlet|
%input#$name$!name=$name$!type=date!:isReq:required!value=$val$
%input#$<name>$!name=$<name>$!type=date!:isReq:required!value=$<val>$
|]
, fpWidget = \name -> do
addScriptRemote "http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"
addScriptRemote "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/jquery-ui.min.js"
addStylesheetRemote "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.1/themes/cupertino/jquery-ui.css"
addHead [$hamlet|%script $$(function(){$$("#$string.name$").datepicker({dateFormat:'yy-mm-dd'})})|]
addHead [$hamlet|%script $$(function(){$$("#$name$").datepicker({dateFormat:'yy-mm-dd'})})|]
}
instance IsFormField Day where
toFormField = requiredField dayField
@ -292,7 +292,7 @@ boolField label tooltip orig = GForm $ \env _ -> do
, fiTooltip = tooltip
, fiIdent = name
, fiInput = addBody [$hamlet|
%input#$string.name$!type=checkbox!name=$string.name$!:val:checked
%input#$name$!type=checkbox!name=$name$!:val:checked
|]
, fiErrors = case res of
FormFailure [x] -> Just $ string x
@ -307,11 +307,11 @@ htmlField = FieldProfile
{ fpParse = Right . preEscapedString
, fpRender = U.toString . renderHtml
, fpHamlet = \name val _isReq -> [$hamlet|
%textarea.html#$name$!name=$name$ $val$
%textarea.html#$<name>$!name=$<name>$ $<val>$
|]
, fpWidget = \name -> do
addScriptRemote "http://js.nicedit.com/nicEdit-latest.js"
addHead [$hamlet|%script bkLib.onDomLoaded(function(){new nicEditor({fullPanel:true}).panelInstance("$string.name$")})|]
addHead [$hamlet|%script bkLib.onDomLoaded(function(){new nicEditor({fullPanel:true}).panelInstance("$name$")})|]
}
instance IsFormField (Html ()) where
toFormField = requiredField htmlField
@ -344,10 +344,10 @@ selectField pairs label tooltip initial = GForm $ \env _ -> do
FormSuccess y -> x == y
_ -> Just x == initial
let input = [$hamlet|
%select#$string.i$!name=$string.i$
%select#$i$!name=$i$
%option!value=none
$forall pairs' pair
%option!value=$string.show.fst.pair$!:isSelected.fst.snd.pair:selected $string.snd.snd.pair$
%option!value=$show.fst.pair$!:isSelected.fst.snd.pair:selected $snd.snd.pair$
|]
let fi = FieldInfo
{ fiLabel = label
@ -381,10 +381,10 @@ maybeSelectField pairs label tooltip initial = GForm $ \env _ -> do
FormSuccess y -> Just x == y
_ -> Just x == initial
let input = [$hamlet|
%select#$string.i$!name=$string.i$
%select#$i$!name=$i$
%option!value=none
$forall pairs' pair
%option!value=$string.show.fst.pair$!:isSelected.fst.snd.pair:selected $string.snd.snd.pair$
%option!value=$show.fst.pair$!:isSelected.fst.snd.pair:selected $snd.snd.pair$
|]
let fi = FieldInfo
{ fiLabel = label

View File

@ -47,17 +47,14 @@ data AtomFeedEntry url = AtomFeedEntry
, atomEntryContent :: Html ()
}
xmlns :: Html ()
xmlns = preEscapedString "http://www.w3.org/2005/Atom"
template :: AtomFeed url -> Hamlet url
template arg = [$xhamlet|
<?xml version="1.0" encoding="utf-8"?>
%feed!xmlns=$xmlns$
%title $string.atomTitle.arg$
%feed!xmlns="http://www.w3.org/2005/Atom"
%title $atomTitle.arg$
%link!rel=self!href=@atomLinkSelf.arg@
%link!href=@atomLinkHome.arg@
%updated $string.formatW3.atomUpdated.arg$
%updated $formatW3.atomUpdated.arg$
%id @atomLinkHome.arg@
$forall atomEntries.arg entry
^entryTemplate.entry^
@ -68,7 +65,7 @@ entryTemplate arg = [$xhamlet|
%entry
%id @atomEntryLink.arg@
%link!href=@atomEntryLink.arg@
%updated $string.formatW3.atomEntryUpdated.arg$
%title $string.atomEntryTitle.arg$
%content!type=html $cdata.atomEntryContent.arg$
%updated $formatW3.atomEntryUpdated.arg$
%title $atomEntryTitle.arg$
%content!type=html $<cdata.atomEntryContent.arg>$
|]

View File

@ -172,7 +172,7 @@ getOpenIdR = do
message <- getMessage
applyLayout "Log in via OpenID" mempty [$hamlet|
$maybe message msg
%p.message $msg$
%p.message $<msg>$
%form!method=get!action=@rtom.OpenIdForward@
%label!for=openid OpenID: $
%input#openid!type=text!name=openid
@ -257,7 +257,7 @@ getCheck = do
$if isNothing.creds
%p Not logged in
$maybe creds c
%p Logged in as $string.credsIdent.c$
%p Logged in as $credsIdent.c$
|]
json creds =
jsonMap
@ -317,7 +317,7 @@ postEmailRegisterR = do
let verUrl = render $ tm $ EmailVerifyR lid verKey
liftIO $ sendVerifyEmail ae email verKey verUrl
applyLayout "Confirmation e-mail sent" mempty [$hamlet|
%p A confirmation e-mail has been sent to $string.email$.
%p A confirmation e-mail has been sent to $email$.
|]
getEmailVerifyR :: YesodAuth master
@ -344,7 +344,7 @@ getEmailLoginR = do
msg <- getMessage
applyLayout "Login" mempty [$hamlet|
$maybe msg ms
%p.message $ms$
%p.message $<ms>$
%p Please log in to your account.
%p
%a!href=@toMaster.EmailRegisterR@ I don't have an account
@ -399,7 +399,7 @@ getEmailPasswordR = do
msg <- getMessage
applyLayout "Set password" mempty [$hamlet|
$maybe msg ms
%p.message $ms$
%p.message $<ms>$
%h3 Set a new password
%form!method=post!action=@toMaster.EmailPasswordR@
%table

View File

@ -52,7 +52,7 @@ getCrudListR = do
$forall items item
%li
%a!href=@toMaster.CrudEditR.toSinglePiece.fst.item@
$string.itemTitle.snd.item$
$itemTitle.snd.item$
%p
%a!href=@toMaster.CrudAddR@ Add new item
|]
@ -103,7 +103,7 @@ getCrudDeleteR s = do
applyLayout "Confirm delete" mempty [$hamlet|
%form!method=post!action=@toMaster.CrudDeleteR.s@
%h1 Really delete?
%p Do you really want to delete $string.itemTitle.item$?
%p Do you really want to delete $itemTitle.item$?
%p
%input!type=submit!value=Yes
\ $
@ -147,8 +147,8 @@ crudHelper title me isPost = do
wrapForm toMaster enctype form = [$hamlet|
%p
%a!href=@toMaster.CrudListR@ Return to list
%h1 $string.title$
%form!method=post!enctype=$string.show.enctype$
%h1 $title$
%form!method=post!enctype=$show.enctype$
%table
^form^
%tr

View File

@ -50,18 +50,15 @@ data SitemapUrl url = SitemapUrl
, priority :: Double
}
sitemapNS :: Html ()
sitemapNS = string "http://www.sitemaps.org/schemas/sitemap/0.9"
template :: [SitemapUrl url] -> Hamlet url
template urls = [$hamlet|
%urlset!xmlns=$sitemapNS$
%urlset!xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
$forall urls url
%url
%loc @sitemapLoc.url@
%lastmod $string.formatW3.sitemapLastMod.url$
%changefreq $string.showFreq.sitemapChangeFreq.url$
%priority $string.show.priority.url$
%lastmod $formatW3.sitemapLastMod.url$
%changefreq $showFreq.sitemapChangeFreq.url$
%priority $show.priority.url$
|]
sitemap :: [SitemapUrl (Routes master)] -> GHandler sub master RepXml

View File

@ -42,7 +42,7 @@ data Location url = Local url | Remote String
deriving (Show, Eq)
locationToHamlet :: Location url -> Hamlet url
locationToHamlet (Local url) = [$hamlet|@url@|]
locationToHamlet (Remote s) = [$hamlet|$string.s$|]
locationToHamlet (Remote s) = [$hamlet|$s$|]
newtype UniqueList x = UniqueList ([x] -> [x])
instance Monoid (UniqueList x) where

View File

@ -83,7 +83,7 @@ class Eq (Routes a) => Yesod a where
!!!
%html
%head
%title $pageTitle.p$
%title $<pageTitle.p>$
^pageHead.p^
%body
^pageBody.p^
@ -176,31 +176,31 @@ defaultErrorHandler NotFound = do
r <- waiRequest
applyLayout' "Not Found" $ [$hamlet|
%h1 Not Found
%p $string.toString.pathInfo.r$
%p $toString.pathInfo.r$
|]
where
pathInfo = W.pathInfo
defaultErrorHandler (PermissionDenied msg) =
applyLayout' "Permission Denied" $ [$hamlet|
%h1 Permission denied
%p $string.msg$
%p $msg$
|]
defaultErrorHandler (InvalidArgs ia) =
applyLayout' "Invalid Arguments" $ [$hamlet|
%h1 Invalid Arguments
%ul
$forall ia msg
%li $string.msg$
%li $msg$
|]
defaultErrorHandler (InternalError e) =
applyLayout' "Internal Server Error" $ [$hamlet|
%h1 Internal Server Error
%p $string.e$
%p $e$
|]
defaultErrorHandler (BadMethod m) =
applyLayout' "Bad Method" $ [$hamlet|
%h1 Method Not Supported
%p Method "$string.m$" not supported
%p Method "$m$" not supported
|]
class YesodPersist y where