Commit 6ed2fcb20a29503806c01ab0b948705f1537a372 Parent: 310fc1dcf24ecfdd5740e4f97fa72253cf032a5f Author: mcol <mcol@posteo.net> Date: 2021-12-04 16:30:13 +0300 Committer: mcol <mcol@posteo.net> Committed: 2021-12-04 16:34:51 +0300 Add template variable to list tree non-recursively Closes #19
src/Repositories.hs Modified
@@ -15,6 +15,7 @@ import Control.Monad.Extra (ifM) import Control.Monad.IO.Class (liftIO) import Control.Monad.Trans.Reader (ReaderT) +import Data.ByteString.UTF8 (toString) import Data.Either (isRight) import qualified Data.HashMap.Strict as HashMap import Data.Maybe (catMaybes, fromJust, mapMaybe) @@ -153,7 +154,8 @@ , ("name", toGVal . pack . init . toFilePath $ name) , ("description", toGVal description) , ("commits", toGVal commits) - , ("tree", toGVal tree) + , ("tree", toGVal . filter (notElem FP.pathSeparator . toString . treeFilePath) $ tree) + , ("tree_recursive", toGVal tree) , ("tags", toGVal tags) , ("branches", toGVal branches) , ("readme", toGVal . findFile "readme" $ tree)
DOCUMENTATION.md Modified
@@ -136,23 +136,24 @@ The variables available within each scope are listed here for reference: -| Scope | Variable | Description | -| ------ | ------------ | ----------------------------------------------------- | -| Index | host | The string from the `host` config option. | -| | repositories | A list of all of the git repositories. | -| Repo | | *In addition to the variables from the index scope...*| -| | name | The repository name, taken from its folder name. | -| | description | The repository's description (see below). | -| | commits | A list of the repository's commits. | -| | tree | A list of the repository's files. | -| | tags | A list of the refs corresponding to tags. | -| | branches | A list of the refs corresponding to branches. | -| | readme | The repository's readme file, if it has one. | -| | license | The repository's license file, if it has one. | -| File | | *In addition to the variables from the Repo scope...* | -| | file | A single file. | -| Commit | | *In addition to the variables from the Repo scope...* | -| | commit | A single commit. | +| Scope | Variable | Description | +| ------ | --------------- | ----------------------------------------------------- | +| Index | host | The string from the `host` config option. | +| | repositories | A list of all of the git repositories. | +| Repo | | *In addition to the variables from the index scope...*| +| | name | The repository name, taken from its folder name. | +| | description | The repository's description (see below). | +| | commits | A list of the repository's commits. | +| | tree | A list of the top-level folder's contents. | +| | tree\_recursive | A list of *all* of the repository's contents. | +| | tags | A list of the refs corresponding to tags. | +| | branches | A list of the refs corresponding to branches. | +| | readme | The repository's readme file, if it has one. | +| | license | The repository's license file, if it has one. | +| File | | *In addition to the variables from the Repo scope...* | +| | file | A single file. | +| Commit | | *In addition to the variables from the Repo scope...* | +| | commit | A single commit. | As in [Jinja](https://jinja.palletsprojects.com), a list can be accessed with indexing, and attributes can be accessed using a dot notation. For example, a