Use convention-based liquid template to conditionally include dynamic content snippets in Power Apps Portals

Use of Content Snippets should be encouraged where appropriate and judicious use of them in web templates vs. web page copy should be included in design. 

To continue the design principle of convention-based development, thereby reducing the amount of code required, consider the frequent occasions when content changes based on the value of an attribute and conditionally include snippets based on that value. 

For example, create three content snippets:

  • “Order/Complete/Resolved”
  • “Order/Complete/Submitted”
  • “Order/Complete/Cancelled”.

The following would then allow for an extendable scenario (e.g. the addition of new statuses) without the need to change code, or have multiple if/else statements.

{% assign primary_record_id = request.params("id") %}
{% assign primary_record = entities.new_order[primary_record_id] %}
{% capture snippet_name %}
{% endcapture %}
{% editable snippets snippet_name %}