Partial trimming
This commit is contained in:
parent
6e14d33a10
commit
430a0a8849
2 changed files with 18 additions and 5 deletions
|
@ -142,7 +142,7 @@ template = mconcat <$> P.many (P.choice [ lift chunk
|
|||
, lift escaped
|
||||
, conditional
|
||||
, for
|
||||
, lift partial
|
||||
, partial
|
||||
, lift expr
|
||||
])
|
||||
where lift = fmap (Template . (:[]))
|
||||
|
@ -246,12 +246,18 @@ for = P.try $ do
|
|||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
partial :: P.Parser TemplateElement
|
||||
partial :: P.Parser Template
|
||||
partial = P.try $ do
|
||||
void $ P.string "$partial("
|
||||
trimLPartial <- trimOpen
|
||||
void $ P.string "partial("
|
||||
e <- expr'
|
||||
void $ P.string ")$"
|
||||
return $ Partial e
|
||||
void $ P.char ')'
|
||||
trimRPartial <- trimClose
|
||||
|
||||
pure $ Template $ mconcat [ [TrimL | trimLPartial]
|
||||
, [Partial e]
|
||||
, [TrimR | trimRPartial]
|
||||
]
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
|
|
@ -68,6 +68,13 @@ tests = testGroup "Hakyll.Core.Template.Tests" $ concat
|
|||
, TrimR
|
||||
]
|
||||
@=? readTemplate "$-for(authors)-$\n body \n$-endfor-$"
|
||||
-- 'Partial' trim check.
|
||||
, Template
|
||||
[ TrimL
|
||||
, Partial (StringLiteral "path")
|
||||
, TrimR
|
||||
]
|
||||
@=? readTemplate "$-partial(\"path\")-$"
|
||||
]
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in a new issue