<p>No. The Twig in Preparse fields is parsed when the element is saved, and there's nothing built in to Preparse (or Craft) that lets you validate or debug the code without actually saving the element.</p>
<p>This sounds like a good feature request either for the <a href="https://github.com/besteadfast/craft-preparse-field" rel="nofollow noreferrer">Preparse</a> field itself or for the Twigfield component it uses. I imagine Preparse could add something like a test or pre-render ability for debugging purposes, and it'd be great if the <a href="https://github.com/nystudio107/craft-twigfield" rel="nofollow noreferrer">Twigfield</a> had Twig syntax error highlighting.</p>
<p>For the interim, to test Preparse fields' output you'll need to resave the element(s) and then check your log files for errors.</p>
<p>Depending on whether the elements are (re)saved via the control panel (i.e. web/http) or the CLI, you'll need to look in either the <code>storage/logs/web-*.log</code> or <code>storage/logs/console-*.log</code> files.</p>
<p><strong>To easily find any Preparse-related items in the log files, do a text search for the plugin namespace, i.e. <code>besteadfast\preparsefield</code>:</strong></p>
<p><a href="https://i.sstatic.net/q5Dbt.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/q5Dbt.png" alt="enter image description here" /></a></p>

CC BY-SA 4.0
2022-10-28T18:48:24.683Z
Thanks, this is very helpful. I also noticed that one can use a template instead:
(snip...)
Preparse also has access to your site's template root, so you can even include local templates if you want to do more advanced stuff and/or want to keep your field's Twig in version control:

{% include '_partials/customPreparseFieldStuff' %}
4midori
CC BY-SA 4.0
2022-11-02T09:35:12.223Z
Correct – you can `{% include %}` templates in Preparse Twig. Possibly this can also be helpful in devising some way of testing/debugging the Twig (i.e. external templates would be relatively simple to render with test data, without having to actually resave any entries w/ the Preparse field. But, again there's no built-in mechanism for this in neither Preparse nor Craft.
Mats Mikkel Rummelhoff
CC BY-SA 4.0
2022-10-28T07:40:12.030Z
2022-10-28T07:40:12.030Z
Mats Mikkel Rummelhoff
<p>I'm trying to use a Preparse field to display something conditionally depending on entries' lastUpdated property. In pseudocode:</p>
<pre><code>if lastUpdated &lt; (now - 30 days)
 **&gt;30 d**
endif
</code></pre>
<p>However, Preparse field has some limitations, and the only way to know if my code is working is to resave my entries and see if it properly parsed my code. There is no way to get a useful error message if my code is wrong. Is there any way to get more useful output?</p>

<entries><control-panel><preparse>
Alternate way to test Preparse field?
# Alternate way to test Preparse field?

(Asked by: username_0 on 2022-10-24)

I'm trying to use a Preparse field to display something conditionally depending on entries' lastUpdated property. In pseudocode:
if lastUpdated < (now - 30 days)
 **>30 d**
endif

However, Preparse field has some limitations, and the only way to know if my code is working is to resave my entries and see if it properly parsed my code. There is no way to get a useful error message if my code is wrong. Is there any way to get more useful output?

**Tags:** entries, control-panel, preparse

---

## 1 answers

### Answer by username_1 on 2022-10-28. Score: 1

No. The Twig in Preparse fields is parsed when the element is saved, and there's nothing built in to Preparse (or Craft) that lets you validate or debug the code without actually saving the element.

This sounds like a good feature request either for the [Preparse](https://github.com/besteadfast/craft-preparse-field) field itself or for the Twigfield component it uses. I imagine Preparse could add something like a test or pre-render ability for debugging purposes, and it'd be great if the [Twigfield](https://github.com/nystudio107/craft-twigfield) had Twig syntax error highlighting.

For the interim, to test Preparse fields' output you'll need to resave the element(s) and then check your log files for errors.

Depending on whether the elements are (re)saved via the control panel (i.e. web/http) or the CLI, you'll need to look in either the `storage/logs/web-*.log` or `storage/logs/console-*.log` files.

**To easily find any Preparse-related items in the log files, do a text search for the plugin namespace, i.e. `besteadfast\preparsefield`:**

[![enter image description here](https://i.sstatic.net/q5Dbt.png)](https://i.sstatic.net/q5Dbt.png)

> **Comments:**
> **username_0**: Thanks, this is very helpful. I also noticed that one can use a template instead: (snip...) Preparse also has access to your site's template root, so you can even include local templates if you want to do more advanced stuff and/or want to keep your field's Twig in version control:  {% include '_partials/customPreparseFieldStuff' %}  
> **username_1**: Correct – you can `{% include %}` templates in Preparse Twig. Possibly this can also be helpful in devising some way of testing/debugging the Twig (i.e. external templates would be relatively simple to render with test data, without having to actually resave any entries w/ the Preparse field. But, again there's no built-in mechanism for this in neither Preparse nor Craft.  

---

