Skip to content

Instantly share code, notes, and snippets.

@waseemsadiq
Created March 5, 2021 23:02
Show Gist options
  • Save waseemsadiq/77177eaaafa900cd19b4f2d0c530d6c7 to your computer and use it in GitHub Desktop.
Save waseemsadiq/77177eaaafa900cd19b4f2d0c530d6c7 to your computer and use it in GitHub Desktop.
HTML to Tailwind class replacement - related to https://gist.github.com/learncss/0dece543913dd601c777b6909b2e30c9
<?php
return [
'ext:pages.template.filter.tailwindclasses' => [
'enable' => true
],
];
<?php
class ExtPagesTemplateFilterTailwindclasses extends ComPagesTemplateFilterAbstract
{
public function filter(&$text)
{
// class="container wrapper"
$text = preg_replace("/class=\"container wrapper\"/","class=\"container border flex flex-col justify-start v-spaced p-4\"", $text);
// class="row
$text = preg_replace("/class=\"row/","class=\"-mx-2 flex flex-wrap", $text);
// class="col"
$text = preg_replace("/class=\"col\"/","class=\"w-full flex px-2 flex-col", $text);
// class="col
$text = preg_replace("/class=\"col /","class=\"w-full flex px-2 flex-col ", $text);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment