Skip to content

Instantly share code, notes, and snippets.

@vanderb
Last active April 24, 2020 14:52
Show Gist options
  • Save vanderb/dc555c4dd75328384ff36fc3d92aa5a8 to your computer and use it in GitHub Desktop.
Save vanderb/dc555c4dd75328384ff36fc3d92aa5a8 to your computer and use it in GitHub Desktop.
MJML Spacer-Classes with PHP & Laravel-Blade
@foreach([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 75, 100] as $space)
@foreach(["top", "bottom", "left", "right"] as $side)
<mj-class name="p{{ substr($side, 0, 1) }}-{{ $space }}" padding-{{ $side }}="{{ $space }}px"/>
@endforeach
@endforeach
// PHP
<?php
foreach([5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 75, 100] as $space) :
foreach(["top", "bottom", "left", "right"] as $side) :
echo sprintf('<mj-class name="p%3$s-%1$d" padding-%2$s="%1$dpx"/>', $space, $side, substr($side, 0, 1));
endforeach;
endforeach;
// padding-top: 5
<mj-section mj-class="pt-5">...</mj-section>
// padding-right: 10
<mj-section mj-class="pr-10">...</mj-section>
// padding-bottom: 25
<mj-section mj-class="pb-25">...</mj-section>
// padding-left: 100
<mj-section mj-class="pl-100">...</mj-section>
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment