Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
fsbraun committed Nov 10, 2024
1 parent cd98fb8 commit 77839bb
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -204,23 +204,15 @@ the new template tag ``to_url``. The ``type`` property returns the link type::

{# Variant 1 #}
{% if obj.link %}
<a href="{{ obj.link.url }}">Link available</a>
<a href="{{ obj.link }}">Link available</a> {# str(obj.link) gives the URL #}
{% endif %}

{# Variant 2 #}
{% load djangocms_link_tags %}
{% if obj.link %}
<a href="{{ obj.link|to_url }}">Link</a>
<a href="{{ obj.link.url }}">Link</a> {# explicitly get the URL #}
{% endif %}

{# Variant 3 #}
{% with url=obj.link|to_url %}
{% if url %}
<a href="{{ url }}">Link available</a>
{% endif %}
{% endwith %}

{% if obj.link.type == "external_link" %}
{% if obj.link.type == "external_link" %} {# evaluate link type #}
<a href="{{ obj.link.url }}">External link</a>
{% endif %}

Expand Down

0 comments on commit 77839bb

Please sign in to comment.