Last active
July 26, 2024 12:09
-
-
Save jarednova/dc75030fd2c7dd6fe52a6fef459c450e to your computer and use it in GitHub Desktop.
Timber Hello World
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# This is a Twig comment, it won't output to the browser #} | |
<html> | |
<head> | |
<title>{{ wp_title }}</title> | |
</head> | |
{% block content %} | |
<!-- This will be overwritten by the content block in the inheriting .twig file --> | |
{% endblock %} | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# This template inherits from `base.twig` #} | |
{% extends "base.twig" %} | |
{% block content %} | |
<h1 class="big-title">{{ foo }}</h1> | |
<h2 class="post-title">{{ post.title }}</h2> | |
<img src="{{ post.thumbnail.src }}" /> | |
<div class="body"> | |
{{ post.content }} | |
</div> | |
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* this will send data from WordPress to the twig files we created */ | |
$context = Timber::get_context(); | |
$context['foo'] = 'BAR!'; | |
$context['post'] = new Timber\Post(); | |
Timber::render('templates/hello-world.twig, $context); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment