You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm implementing a function partialWithContextJSONFile that takes two parameters: $partialWithContextJSONFile("mytemplate.html", "myenv.json")$, where myenv.json is a file containing a json file that will be used as a context. So to load that file in my functionField definition, I use:
in the place where I define all the rules, otherwise I get an error:
Hakyll.Core.Compiler.Require.load: menu.json (snapshot _final) was not found in the cache, the cache might be corrupted or the item you are referring to might not exist
The thing is that I'd prefer to do the compilation directly in the functionField part. Any idea how I could do that? For now, here is the first part of my Context function:
partialWithContextJSONFile :: Context String
partialWithContextJSONFile = functionField "partialWithContextJSONFile" $ \args page -> do
case args of
[pathTemplate, pathJson] -> do
template <- loadBody (fromFilePath pathTemplate)
jsonBody <- B.fromString <$> loadBody (fromFilePath pathJson)
let eitherJson = Aeson.eitherDecodeStrict' jsonBody
[...]
Thanks for your answer. I used a similar solutions before (I was using directly the Aeson function to load files + unsafeCompiler to perform the IO), but my issue is that it seems that the compiler does not notify the changes on the .json file (need to restart the server and clear the cache), so I guess that I need somehow to say "oh, if that files changes, then recompile me".
Hello,
I'm implementing a function
partialWithContextJSONFile
that takes two parameters:$partialWithContextJSONFile("mytemplate.html", "myenv.json")$
, wheremyenv.json
is a file containing a json file that will be used as a context. So to load that file in myfunctionField
definition, I use:but for this to work, I need to do:
in the place where I define all the rules, otherwise I get an error:
The thing is that I'd prefer to do the compilation directly in the
functionField
part. Any idea how I could do that? For now, here is the first part of myContext
function:Thanks!
-- EDIT --
It may be related to #802 ?
The text was updated successfully, but these errors were encountered: