Skip to content

Instantly share code, notes, and snippets.

@callaginn
Last active June 28, 2024 22:55
Show Gist options
  • Save callaginn/85a376b31c1c5db525eb358112591292 to your computer and use it in GitHub Desktop.
Save callaginn/85a376b31c1c5db525eb358112591292 to your computer and use it in GitHub Desktop.
Dreamweaver to Twig Migration

1. Replace ssi include with twig include:

Find: <!--#include virtual="\/includes\/(.+).ssi" -->
Replace: {% include '$1.twig' %}

Modification of that, which supports file includes as well:

Find: <!--#include (?:virtual|file)="(.+).ssi" -->
Replace: {% include '$1.twig' %}

You can always go back later and replace the following with a blank string:

Find: (?<={% include ')\/?includes\/
Replace:

2. Find and replace DW Variables:

Find: <!-- InstanceParam name="(.+)" .+ value="(.+)" -->
Replace: {% set $1 = "$2" %}

3. Find and Replace HTML Comments:

Find: <!--(.+)-->
Replace: {# $1 #}

Here's a version with multiline support:

Find: <!--([\s\S]*?)-->
Replace: {# $1 #}

Trim replaced twig comments:

Find: {#\s?(.+)\s?#}
Replace: {# $1 #}

4. Find and Replace DW Editable Region:

Find: <!-- InstanceBeginEditable name="Main" ?-->([\S\s]+?)<!-- ?InstanceEndEditable
Replace: {% block content %}$1{% endblock %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment