Skip to content

Commit

Permalink
Build
Browse files Browse the repository at this point in the history
  • Loading branch information
gchtr committed Jul 31, 2023
1 parent 6337b82 commit 183093f
Show file tree
Hide file tree
Showing 153 changed files with 3,187 additions and 12,156 deletions.
6 changes: 3 additions & 3 deletions _data/mixManifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"/js/app.js": "/js/app.js?id=1bda1fde1ad4728c63bb3cc0cb17c53a",
"/css/mobile.css": "/css/mobile.css?id=1c0c81d39ce0cbfc4cbdf7f7c93c61db",
"/css/styles.css": "/css/styles.css?id=c6dd6fc0dc4152fa1eba764426fa484a",
"/js/app.js": "/js/app.js?id=4594e1490acc2ce9d471fb2243cbcfce",
"/css/mobile.css": "/css/mobile.css?id=eb03f5e9c806ca82b2fc8d728401461a",
"/css/styles.css": "/css/styles.css?id=9a52d408892dbfb99fcc806a26146606",
"/img/github.png": "/img/github.png?id=3f926224bc6fafa2829773067f246487",
"/img/timber-logo.svg": "/img/timber-logo.svg?id=f723c6fbc3613d9286dea51365236056",
"/favicons/apple-touch-icon-114x114.png": "/favicons/apple-touch-icon-114x114.png?id=288cb0e7c0b15e62d3523f1530ef90c3",
Expand Down
2 changes: 1 addition & 1 deletion build/css/mobile.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/css/styles.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/js/app.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions build/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"/js/app.js": "/js/app.js?id=1bda1fde1ad4728c63bb3cc0cb17c53a",
"/css/mobile.css": "/css/mobile.css?id=1c0c81d39ce0cbfc4cbdf7f7c93c61db",
"/css/styles.css": "/css/styles.css?id=c6dd6fc0dc4152fa1eba764426fa484a",
"/js/app.js": "/js/app.js?id=4594e1490acc2ce9d471fb2243cbcfce",
"/css/mobile.css": "/css/mobile.css?id=eb03f5e9c806ca82b2fc8d728401461a",
"/css/styles.css": "/css/styles.css?id=9a52d408892dbfb99fcc806a26146606",
"/img/github.png": "/img/github.png?id=3f926224bc6fafa2829773067f246487",
"/img/timber-logo.svg": "/img/timber-logo.svg?id=f723c6fbc3613d9286dea51365236056",
"/favicons/apple-touch-icon-114x114.png": "/favicons/apple-touch-icon-114x114.png?id=288cb0e7c0b15e62d3523f1530ef90c3",
Expand Down
8 changes: 6 additions & 2 deletions content/v2/getting-started/a-post-archive.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ You can then loop over your posts with a [for-loop in Twig](https://twig.symfony
<ul>
{% endif %}
{{ include('pagination.twig') }}
{{ include('pagination.twig') }}
{% endblock %}
```

Expand All @@ -45,6 +45,9 @@ Your teaser could look like this. We used the markup for an [Inclusive Card](htt
<img
src="{{ post.thumbnail.src('medium') }}"
alt="{{ post.thumbnail.alt }}"
width="{{ post.thumbnail.width }}"
height="{{ post.thumbnail.height }}"
loading="lazy"
>
<h2>
Expand All @@ -71,7 +74,7 @@ There are two new things that you see here:

## Using custom queries

Sometimes you’ll want to use your own queries for archive pages or to display a list of posts in other places. For that, you can use `Timber::get_posts()`. Here’s an example for a more complex query, that selects posts that have certain movie genre and actor terms assigned. The parameters you use are the same as those for [WP_Query](https://developer.wordpress.org/reference/classes/wp_query/).
Sometimes you’ll want to use your own queries for archive pages or to display a list of posts in other places. For that, you can use `Timber::get_posts()`. Here’s an example for a more complex query, that selects posts that have certain movie genres and actor terms assigned. The parameters you use are the same as those for [WP_Query](https://developer.wordpress.org/reference/classes/wp_query/).

```php
$args = [
Expand Down Expand Up @@ -111,6 +114,7 @@ $post = $context['post'];
$context['related_posts'] = Timber::get_posts([
'post_type' => 'post',
'posts_per_page' => 3,
'no_found_rows' => true,
'orderby' => 'date',
'order' => 'DESC',
'post__not_in' => [$post->ID],
Expand Down
2 changes: 1 addition & 1 deletion content/v2/getting-started/a-single-post.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,4 @@ Timber::render('single.twig', $context);

Now, you can head on to the next chapter about [Post Archives](https://timber.github.io/docs/v2/getting-started/a-post-archive/).

If you want to know more about advanced methods to extend Timber, you can learn about it in the [Extending Timber Guide](https://timber.github.io/docs/guides/v2/extending-timber/).
If you want to know more about advanced methods to extend Timber, you can learn about it in the [Extending Timber Guide](https://timber.github.io/docs/v2/guides/extending-timber/).
2 changes: 1 addition & 1 deletion content/v2/getting-started/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ See how there’s no HTML in our PHP file? And do you see how we fetch the data

In Timber, we prepare a lot for you in the background, so you don’t have to remember function names like `get_the_title()`.

Most of Timber’s templates look like this:
Most Timber templates look like this:

**index.php**

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ For this introduction, let’s assume that the name of the page is "All about Ja
{% block headline %}
<header>
<h1 class="article-title">{{ post.title }}</h1>
<p role="doc-subtitle">{{ post.subtitle }}</h2>
<p role="doc-subtitle">{{ post.subtitle }}</p>
</header>
{% endblock %}
<p class="article-author"><span>By</span> {{ post.author.name }} <span>&bull;</span> {{ post.post_date }}</p>
<p class="article-author"><span>By</span> {{ post.author.name }} <span>&bull;</span> {{ post.date }}</p>
{{ post.content }}
</section>
Expand Down Expand Up @@ -141,7 +141,7 @@ So there are two big concepts going on here:
1. **Multiple Inheritance:** We’re extending **single.twig**, which itself extends **base.twig**. Thus we stay true to the [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself) principle and don’t have very similar code between our two templates hanging around.
2. **Nested Blocks:** `{% block headline %}` is located inside `{% block content %}`. So while we’re replacing the headline, we get to keep all the other markup and variables found in the parent template.

What if you wanted to **add** something to the block as opposed to replace? In this case you can [`{{ parent() }}`](https://twig.symfony.com/doc/functions/parent.html) where the parent block’s content should go.
What if you wanted to **add** something to the block as opposed to replace? In this case you can use [`{{ parent() }}`](https://twig.symfony.com/doc/functions/parent.html) where the parent block’s content should go.

```twig
{% extends "single.twig" %}
Expand Down
2 changes: 1 addition & 1 deletion content/v2/guides/date-time.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ DateTimeHelper::time_ago($post->date());
**Twig**

```twig
{{ post.date|time_ago }}
{{ post.date('U')|time_ago }}
```

**HTML**
Expand Down
2 changes: 1 addition & 1 deletion content/v2/guides/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ Check out the [Extending Twig Guide](https://timber.github.io/docs/v2/guides/ext

The concept of Timber (and templating engines like Twig in general) is to prepare all the data before you pass it to a template. Some functions in WordPress echo their output directly. We don’t want this, because the output of this function would be echoed before we call `Timber:render()` and appear before every else on your website. There are two ways to work around this:

- If you have a function where you want to bypass the output and instead save it as a string, so that you can add it to your context, use [`Helper::ob_function`](https://timber.github.io/docs/v2/reference/timber-helper/#ob-function).
- If you have a function where you want to bypass the output and instead save it as a string, so that you can add it to your context, use [`Helper::ob_function`](https://timber.github.io/docs/v2/reference/timber-helper/#ob_function).
- If you have a function that needs to be called exactly where you use it in your template (e.g. because it depends on certain global values) you can use `FunctionWrapper`:

```php
Expand Down
65 changes: 28 additions & 37 deletions content/v2/reference/timber-attachment.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ objects build upon.

| Name | Type | Description |
| --- | --- | --- |
| <span class="property-name">$file</span> | <span class="property-type">`mixed`</span> | <span class="property-description"></span> |
| <span class="property-name">$file</span> | <span class="property-type">`string`</span> | <span class="property-description"></span> |
| <span class="property-name">$file_loc</span> | <span class="property-type">`string`</span> | <span class="property-description">The absolute path to the attachmend file in the filesystem (Example: `/var/www/htdocs/wp-content/uploads/2015/08/my-pic.jpg`)</span> |
| <span class="property-name">$file_size</span> | <span class="property-type">`\Timber\FileSize`</span> | <span class="property-description">File size string.</span> |
| <span class="property-name">$file_extension</span> | <span class="property-type">`null` or `string`</span> | <span class="property-description">A file extension.</span> |
| <span class="property-name">$id</span> | <span class="property-type">`int`</span> | <span class="property-description">The attachment ID.</span> |
| <span class="property-name">$file_extension</span> | <span class="property-type">`string`</span> | <span class="property-description">A file extension.</span> |

</div>

Expand All @@ -36,13 +34,14 @@ objects build upon.
| --- | --- | --- |
| <span class="method-name">[__toString()](#__toString)</span> | <span class="method-type">`string`</span> | <span class="method-description">Gets the src for an attachment.<br><br><span class="method-return"><span class="method-return-label">Returns:</span> The src of the attachment.</span></span> |
| <span class="method-name">[caption()](#caption)</span> | <span class="method-type">`string`</span> | <span class="method-description">Gets the caption of an attachment.</span> |
| <span class="method-name">[extension()](#extension)</span> | <span class="method-type">`string` or `null`</span> | <span class="method-description">Gets the extension of the attached file.<br><br><span class="method-return"><span class="method-return-label">Returns:</span> An uppercase extension string.</span></span> |
| <span class="method-name">[extension()](#extension)</span> | <span class="method-type">`string`</span> | <span class="method-description">Gets the extension of the attached file.<br><br><span class="method-return"><span class="method-return-label">Returns:</span> An uppercase extension string.</span></span> |
| <span class="method-name">[file()](#file)</span> | <span class="method-type">`string`</span> | <span class="method-description">Gets the relative path to the uploads folder of an attachment.</span> |
| <span class="method-name">[file_loc()](#file_loc)</span> | <span class="method-type">`string`</span> | <span class="method-description">Gets the absolute path to an attachment.</span> |
| <span class="method-name">[link()](#link)</span> | <span class="method-type">`string`</span> | <span class="method-description">Gets the link to an attachment.<br><br><span class="method-return"><span class="method-return-label">Returns:</span> The URL of the attachment.</span></span> |
| <span class="method-name">[parent()](#parent)</span> | <span class="method-type">`false` or `\Timber\Post`</span> | <span class="method-description">Gets the parent object.<br><br><span class="method-return"><span class="method-return-label">Returns:</span> Parent object as a `Timber\Post`. Returns `false` if no parent object is defined.</span></span> |
| <span class="method-name">[parent()](#parent)</span> | <span class="method-type">`null` or `\Timber\Post`</span> | <span class="method-description">Gets the parent object.<br><br><span class="method-return"><span class="method-return-label">Returns:</span> Parent object as a `Timber\Post`. Returns `false` if no parent object is defined.</span></span> |
| <span class="method-name">[path()](#path)</span> | <span class="method-type">`string`</span> | <span class="method-description">Gets the relative path to an attachment.<br><br><span class="method-return"><span class="method-return-label">Returns:</span> The relative path to an attachment.</span></span> |
| <span class="method-name">[size()](#size)</span> | <span class="method-type">`string` or `null`</span> | <span class="method-description">Gets filesize in a human readable format.<br><br><span class="method-return"><span class="method-return-label">Returns:</span> The filesize string in a human-readable format or null if the filesize can’t be read.</span></span> |
| <span class="method-name">[size_raw()](#size_raw)</span> | <span class="method-type">`int` or `false`</span> | <span class="method-description">Gets filesize in bytes.<br><br><span class="method-return"><span class="method-return-label">Returns:</span> The filesize string in bytes, or false if the filesize can’t be read.</span></span> |
| <span class="method-name">[src()](#src)</span> | <span class="method-type">`bool` or `string`</span> | <span class="method-description">Gets the source URL for an attachment.</span> |
| <span class="method-name">[size()](#size)</span> | <span class="method-type">`int` or `null`</span> | <span class="method-description">Gets filesize in a human readable format.<br><br><span class="method-return"><span class="method-return-label">Returns:</span> The filesize string in a human-readable format or null if the filesize can’t be read.</span></span> |
| <span class="method-name">[src()](#src)</span> | <span class="method-type">`string`</span> | <span class="method-description">Gets the source URL for an attachment.</span> |

</div>

Expand Down Expand Up @@ -99,11 +98,27 @@ Gets the relative path to an attachment.

---

### file()

Gets the relative path to the uploads folder of an attachment.

**Returns:** `string`

---

### file\_loc()

Gets the absolute path to an attachment.

**Returns:** `string`

---

### src()

Gets the source URL for an attachment.

**Returns:** `bool|string`
**Returns:** `string`

**Twig**

Expand Down Expand Up @@ -149,7 +164,7 @@ easier to read «16 KB» than «16555 bytes» or «1 MB» than «1048576 bytes»

**since** 2.0.0

**Returns:** `string|null` The filesize string in a human-readable format or null if the
**Returns:** `int|null` The filesize string in a human-readable format or null if the
filesize can’t be read.

Use filesize information in a link that downloads a file:
Expand All @@ -165,37 +180,13 @@ Use filesize information in a link that downloads a file:

---

### size\_raw()

Gets filesize in bytes.

**since** 2.0.0

**Returns:** `int|false` The filesize string in bytes, or false if the filesize can’t be read.

**Twig**

```twig
<table>
{% for attachment in Attachment(attachment_ids) %}
<tr>
<td>{{ attachment.title }}</td>
<td>{{ attachment.extension }}</td>
<td>{{ attachment.size_raw }} bytes</td>
</tr>
{% endfor %}
</table>
```

---

### extension()

Gets the extension of the attached file.

**since** 2.0.0

**Returns:** `string|null` An uppercase extension string.
**Returns:** `string` An uppercase extension string.

Use extension information in a link that downloads a file:

Expand All @@ -218,7 +209,7 @@ Gets the parent object.

The parent object of an attachment is a post it is assigned to.

**Returns:** `false|\Timber\Post` Parent object as a `Timber\Post`. Returns `false` if no parent
**Returns:** `null|\Timber\Post` Parent object as a `Timber\Post`. Returns `false` if no parent
object is defined.

**Twig**
Expand Down
30 changes: 30 additions & 0 deletions content/v2/reference/timber-datetimehelper.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Helper class to work with dates and times.

| Name | Return Type | Summary/Returns |
| --- | --- | --- |
| <span class="method-name">[time_ago()](#time_ago)</span> | <span class="method-type">`string`</span> | <span class="method-description">Returns the difference between two times in a human readable format.</span> |
| <span class="method-name">[wp_date()](#wp_date)</span> | <span class="method-type">`false` or `string`</span> | <span class="method-description">Wrapper for wp_date().</span> |

</div>
Expand All @@ -41,3 +42,32 @@ Wrapper for wp_date().

---

### time\_ago()

Returns the difference between two times in a human readable format.

Differentiates between past and future dates.

**see** human_time_diff()

`time_ago( int|string $from, int|string $to = null, string $format_past = null, string $format_future = null )`

**Returns:** `string`

| Name | Type | Description |
| --- | --- | --- |
| $from | `int` or `string` | Base date as a timestamp or a date string. |
| $to | `int` or `string` | Optional. Date to calculate difference to as a timestamp or a date string. Default current time. |
| $format_past | `string` | Optional. String to use for past dates. To be used with `sprintf()`. Default `%s ago`. |
| $format_future | `string` | Optional. String to use for future dates. To be used with `sprintf()`. Default `%s from now`. |

**Twig**

```twig
{{ post.date('U')|time_ago }}
{{ post.date('Y-m-d H:i:s')|time_ago }}
{{ post.date(constant('DATE_ATOM'))|time_ago }}
```

---

Loading

0 comments on commit 183093f

Please sign in to comment.