mirror of
https://github.com/srid/rib.git
synced 2024-11-27 01:12:09 +03:00
Add singular version of buildHtmlMulti
buildHtml was incorrectly named; it should have actually been called writeHtml. This commit also actually implements buildHtml, which is like buildHtmlMulti but operating on a single file.
This commit is contained in:
parent
916f671b3a
commit
7ec05a94af
@ -9,10 +9,11 @@
|
|||||||
-- See the source of `Rib.Simple.buildAction` for example usage.
|
-- See the source of `Rib.Simple.buildAction` for example usage.
|
||||||
module Rib.Shake
|
module Rib.Shake
|
||||||
( -- * Basic helpers
|
( -- * Basic helpers
|
||||||
|
readSource,
|
||||||
buildStaticFiles,
|
buildStaticFiles,
|
||||||
buildHtmlMulti,
|
buildHtmlMulti,
|
||||||
buildHtml,
|
buildHtml,
|
||||||
readSource,
|
writeHtml,
|
||||||
|
|
||||||
-- * Misc
|
-- * Misc
|
||||||
RibSettings (..),
|
RibSettings (..),
|
||||||
@ -95,18 +96,26 @@ buildHtmlMulti ::
|
|||||||
buildHtmlMulti pats parser r = do
|
buildHtmlMulti pats parser r = do
|
||||||
input <- ribInputDir
|
input <- ribInputDir
|
||||||
fs <- getDirectoryFiles' input pats
|
fs <- getDirectoryFiles' input pats
|
||||||
forP fs $ \k -> do
|
forP fs $ \k -> buildHtml k parser r
|
||||||
src <- readSource parser k
|
|
||||||
outfile <- liftIO $ replaceExtension ".html" k
|
|
||||||
writeFileCached outfile $ toString $ Lucid.renderText $ r src
|
|
||||||
pure src
|
|
||||||
|
|
||||||
-- | Build a single HTML file with the given HTML value
|
-- | Like buildHtmlMulti but operates on a single file.
|
||||||
|
buildHtml ::
|
||||||
|
Path Rel File ->
|
||||||
|
SourceReader repr ->
|
||||||
|
(Source repr -> Html ()) ->
|
||||||
|
Action (Source repr)
|
||||||
|
buildHtml k parser r = do
|
||||||
|
src <- readSource parser k
|
||||||
|
outfile <- liftIO $ replaceExtension ".html" k
|
||||||
|
writeHtml outfile $ r src
|
||||||
|
pure src
|
||||||
|
|
||||||
|
-- | Write a single HTML file with the given HTML value
|
||||||
--
|
--
|
||||||
-- The HTML text value will be cached, so subsequent writes of the same value
|
-- The HTML text value will be cached, so subsequent writes of the same value
|
||||||
-- will be skipped.
|
-- will be skipped.
|
||||||
buildHtml :: Path Rel File -> Html () -> Action ()
|
writeHtml :: Path Rel File -> Html () -> Action ()
|
||||||
buildHtml f = writeFileCached f . toString . Lucid.renderText
|
writeHtml f = writeFileCached f . toString . Lucid.renderText
|
||||||
|
|
||||||
-- | Like writeFile' but uses `cacheAction`.
|
-- | Like writeFile' but uses `cacheAction`.
|
||||||
--
|
--
|
||||||
|
Loading…
Reference in New Issue
Block a user