Is there a way—using Twig—to check if a variable is set based on a string of the same name?
In this example below, editLink.object
is a string with the value of "entryAlias". I want to check to see if a variable, entryAlias
, has been set and to see if it's an entry.
{% if "#{editLink.object}" is same as(editLink.object) %}
it workes
{% else %}
not so much
{% endif %}
I've looked into same as
and is
, but I think the problem I'm having is converting the string to an object. Also, I'm pretty sure this can just be done using PHP, but I'd like to see if it can be done within Craft's Twig so this can be cached as part of a template.