Theme Debugging

As you develop LemonStand themes, there are times you need more information than the documentation can provide. The LemonStand theme engine includes a special debugging function for displaying the value of various theme variables.

{{ describe( variableName ) }}

Prints a template variable in JSON format. Useful for referencing available values, diagnostics, and integrating Twig objects with JavaScript code. You can use describe in any LemonStand template page, partial, and so on.

Printing LemonStand Variables

You can display any of the built in LemonStand variables by using describe.

To print the theme variable, place it in a describe call in one of your theme page templates or partials:

{{ describe(theme) }}

The PRE block applies a fixed-width font and makes the output easier to read. The above call dumps the theme object as JSON text:

    "logoImage": {},
    "bannerImage": {},
    "bannerTitleText": "Zest",
    "bannerSentenceText": "A responsive LemonStand theme",
    "globalLinkColor": "#dc3e2f",
    "globalLinkHoverColor": "#9f261b",
    "salePriceColor": "#dc3e2f",
    "saleBadgeColor": "#dc3e2f",
    "buttonColor": "#dc3e2f",
    "buttonHoverColor": "#b92c1f",
    "buttonBorderColor": "#dc3e2f",
    "faviconImage": {}

You can use describe to print any LemonStand variable, as long as it is available to the page or partial. For example, you can only print productvariables on product pages, and category variables from within a category loop.

Printing Variables from loops

To print out the contents of the category variable, include the describe from within the standard category tree loop:

{% tree categories %}
       {% for category in tree.items %}
{{ describe(category) }}
{% branch category.children %}
       {% endfor %}
{% endtree %}

Additional examples

You can also print out individual variable members using describe:

{{ describe(product.enabled) }}

This will print the status of the enabled flag on the product object (assuming that the product object is in scope).

You can describe as many variables as you need to:

{{ describe(product) }}
{{ describe(cart) }}
{{ describe(customer) }}
{{ describe(category) }}
{{ describe(checkout) }}
{{ describe(order) }}
{{ describe(theme) }}