pencil-1.0.1: Static site generator

Safe HaskellNone
LanguageHaskell2010

Pencil

Contents

Description

Main Pencil module. This module re-exports most functions, so you should only need to import this one.

Synopsis

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.

Blogging

This module provides out-of-the-box blogging functionality. Read through the blogging tutorial to learn how to use it.

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

The Pencil Type

Provides the main Pencil type that everything runs in.

module Pencil.App

Re-exports

asks #

Arguments

:: MonadReader r m 
=> (r -> a)

The selector function to apply to the environment.

-> m a 

Retrieves a function of the current environment.

local #

Arguments

:: MonadReader r m 
=> (r -> r)

The function to modify the environment.

-> m a

Reader to run in the modified environment.

-> m a 

Executes a computation in a modified environment.