Safe Haskell | None |
---|---|
Language | Haskell2010 |
Main Pencil module. This module re-exports most functions, so you should only need to import this one.
Synopsis
- module Pencil.Content
- module Pencil.Blog
- module Pencil.Env
- module Pencil.Config
- module Pencil.App
- asks :: MonadReader r m => (r -> a) -> m a
- local :: MonadReader r m => (r -> r) -> m a -> m a
Getting started
Pencil helps you build static websites in Haskell. Write your website's content in HTML or Markdown, and use the power of Pencil to compose components together into HTML pages.
The best way to get started is to follow the tutorials and guides found at elbenshira.com/pencil.
Here is a simple website of a couple of pages, based off this example:
module Main where import Pencil website :: PencilApp () website = do layout <- load "layout.html" index <- load "index.markdown" render (layout <|| index) loadAndRender "stylesheet.scss" main :: IO () main = run website defaultConfig
To learn more, dig into the tutorials and guides found on elbenshira.com/pencil.
Templates
Pencil comes with a simple templating engine. Templates allow us to build web pages dynamically using Haskell code. Blog posts, for example, can share a common HTML template.
Pencil's templating engine comes with variables, if blocks, for loops, and partials. Read the templates guide for a thorough walk-through.
Example:
<ul> ${for(posts)} <li><a href="${this.url}">${postTitle}</a> - ${date}</li> ${end} </ul>
Pages, Structures and Resources
Page
, Structure
and Resource
are the "big three" data types you need to
know to effectively use Pencil.
The Pages and Structures guide introduces these important data types. The documentation found here goes into further detail.
module Pencil.Content
Blogging
This module provides out-of-the-box blogging functionality. Read through the blogging tutorial to learn how to use it.
module Pencil.Blog
Environment Manipulation
The environment is where variables live. Composing web pages together implies composing environments. This is where Pencil's power lies: in helping you easily build the proper environment to render your web pages.
To get started, read the environment guide.
module Pencil.Env
Configuration
module Pencil.Config
The Pencil Type
Provides the main Pencil type that everything runs in.
module Pencil.App
Re-exports
:: MonadReader r m | |
=> (r -> a) | The selector function to apply to the environment. |
-> m a |
Retrieves a function of the current environment.
:: MonadReader r m | |
=> (r -> r) | The function to modify the environment. |
-> m a |
|
-> m a |
Executes a computation in a modified environment.