Fork me on GitHub

Twig Compatibility

While Pebble was inspired by and generally has high compatibility with Twig, it is neither a complete nor an exact Twig implementation. There are features of Twig not supported by Pebble, there are features implemented in Pebble that are not supported by Twig, and some features might behave differently or use a different name or syntax. This page outlines the similarities and differences between Pebble and Twig.


Name Pebble Support Notes
autoescape full (docs)
block full (docs)
do none
embed partial (docs)

only clause and ignore missing clause not supported

extends full (docs)
filter full (docs)
flush none
for full (docs)
from full (docs)
if full (docs)
import full (docs)
include partial (docs)

only clause and ignore missing clause not supported

macro full (docs)
sandbox none
set full (docs)
spaceless none
use none
verbatim full (docs)
with none


Name Pebble Support Notes
abs full (docs)
batch none
capitalize full (docs)
convert_encoding none
date partial (docs)

This filter uses java.util.Date date formatting instead of PHP-style formatting.

date_modify none
default full (docs)
escape full (docs)
first full (docs)
format none
join none (docs)
json_encode none
keys none
last full (docs)
length full (docs)
lower full (docs)
merge none
nl2br none
number_format partial (docs)

Filter is named numberformat, and uses java.text.DecimalFormat formatting instead of PHP-style formatting.

raw full (docs)
replace full (docs)
reverse full (docs)
round none
slice full (docs)
sort full (docs)
split full (docs)
striptags none
title full (docs)
trim full (docs)
upper full (docs)
url_encode partial (docs)

Filter is named urlencode.


Name Pebble Support Notes
attribute none
block full (docs)
constant none
cycle none
date none
dump none
include none
max full (docs)
min full (docs)
parent full (docs)
random none
range full (docs)
source none
template_from_string none


Name Pebble Support Notes
constant none
defined none
divisible by none
empty full (docs)
even full (docs)
iterable full (docs)
null full (docs)
odd full (docs)
same as none


Name Pebble Support Notes
in none (docs)

contains can be used instead

is full (docs)
Math (+, -, /, %, //, *, **) partial (docs)

// and ** not supported

Logic (and, or, not, (), b-and, b-xor, b-or) partial (docs)

Bitwise logical operators are not supported

Comparisons (==, !=, <, >, >=, <=, ===, starts with, ends with, matches) partial (docs)

===, starts with, ends with, and matches not supported

Others (.., |, ~, ., [], ?:) full (docs)

subscript operator [] index starts at 0, not 1