Popularity
4.6
Declining
Activity
0.0
Stable
4
4
2

Monthly Downloads: 27
Programming language: Haskell
License: BSD 3-clause "New" or "Revised" License
Tags: Text    
Latest version: v0.2.0.3

HSmarty alternatives and similar packages

Based on the "Text" category.
Alternatively, view HSmarty alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of HSmarty or a related project?

Add another 'Text' Package

README

HSmarty

CircleCI

Haskell implementation of a subset of the PHP-Smarty template language.

Usage

{-# LANGUAGE OverloadedStrings #-}
module Main where

import Text.HSmarty

import qualified Data.HashMap.Strict as HM
import qualified Data.Text as T

main :: IO ()
main =
   renderTemplate "test.tpl" $
   HM.fromList [ ( "title", mkParam ("SomeTitle" :: T.Text))
               , ( "list", mkParam (["a", "b"] :: [T.Text]))
               ]

Implemented features

  • Basic template parsing (See Basic Syntax)
  • Smarty comments
  • Basic expressions (eg. $var, $var.mapItem, $var[3], $var@property, 3+4, ..)
  • Branching (eg. {if ..}, {elseif ..}, {else}, ..)
  • Looping with properties (eg. {foreach $el as $k=>$v}, {$v@last}, {foreachelse}, {/foreach})
  • Including other templates ({include file='other.tpl'})
  • Defining functions ({function name='foo'}...{/function})
  • Calling functions ({foo arg1="bar"})
  • Assigning variables ({$foo=1+2+3})
  • Capturing output into variables ({capture name='blabla'}<b>{$some}</b>{/capture})

Non-Smarty features

  • Explicit scoping blocks ({scope}{$localFoo=123}{$localFoo}{/scope}{* $localFoo not available here! *})

Contributing

All constributions adding features of the "original" PHP-Smarty V3 are welcome. For any other contributions please discuss in an issue first. Note that by sending a PR you agree that all your code can be released under the BSD3 license as part of this project or otherwise.


*Note that all licence references and agreements mentioned in the HSmarty README section above are relevant to that project's source code only.