clusterBuddy
clusterBuddy

Reputation: 1554

Wordpress + Timber + Twig

in index.php (entry file) I have a $context["home-page"] = home_url(); yet for some reason when I implement it as <a href="{{ home-page }}">hello.com</a>. When rendering, I get a "0" value in href attribute: hello.com

when I dump that context value, I get this erroneous reply:

\wp-content\themes\hello\vendor\twig\twig\lib\Twig\Extension\Debug.php:50:int 0

Keep in mind that all the other contexts Work fine, such as:

Is this somethin familiar to any of you?

Upvotes: 0

Views: 1139

Answers (1)

Luckyfella
Luckyfella

Reputation: 662

Please try it this way:

$context["home_page"]

Instead of

$context["home-page"]

In twig templates {{ home-page }} should be interpreted as a substraction of variable home with variable page.

Edit: And like @DarkBee suggested you would have to define the variables before you can use them. That is why you get the error when debugging the context object.

Upvotes: 1

Related Questions