Template
Simple string substitution for Haskell.
Install / Use
/learn @tibbe/TemplateREADME
Template strings
Simple string substitution library that supports "$"-based
substitution. Meant to be used when Text.Printf or string
concatenation would lead to code that is hard to read but when a full
blown templating system is overkill.
Usage example:
{-# LANGUAGE OverloadedStrings #-}
module Main where
import qualified Data.ByteString.Lazy as S
import qualified Data.Text as T
import qualified Data.Text.Lazy.Encoding as E
import Data.Text.Template
-- | Create 'Context' from association list.
context :: [(T.Text, T.Text)] -> Context
context assocs x = maybe err id . lookup x $ assocs
where err = error $ "Could not find key: " ++ T.unpack x
main :: IO ()
main = S.putStr $ E.encodeUtf8 $ substitute helloTemplate helloContext
where
helloTemplate = "Hello, $name!\n"
helloContext = context [("name", "Joe")]
Related Skills
node-connect
351.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
