PAD Showcase
All tags/Emoji

Shortcodes in text

The emoji pipe turns every shortcode in a text into its emoji - one it does not know, or a time like 10:30:00, stays as written.

1 The data emoji/chat.php php
<?php

  // Messages as people type them, shortcodes and all.

  $messages = [
    [ 'who' => 'Ana',   'text' => 'The build is green :white_check_mark: shipping it :rocket:' ],
    [ 'who' => 'Bram',  'text' => 'Nice work :clap: :clap:' ],
    [ 'who' => 'Chen',  'text' => 'Coffee at 10:30:00? :coffee:' ],
    [ 'who' => 'Dewi',  'text' => 'Count me in :raised_hand: - and :not_a_code: stays as it is' ],
  ];

?>
2 The template emoji/chat.pad pad
<ul style="list-style:none;margin:0;padding:0;max-width:30em;display:grid;gap:10px">
  {messages}
  <li style="padding:10px 14px;border-radius:14px;background:rgba(42,120,214,.1);line-height:1.5"><strong>{$who}</strong>: {$text | emoji}</li>
  {/messages}
</ul>
3 The result rendered on the server
  • Ana: The build is green โœ… shipping it ๐Ÿš€
  • Bram: Nice work ๐Ÿ‘ ๐Ÿ‘
  • Chen: Coffee at 10:30:00? โ˜•
  • Dewi: Count me in โœ‹ - and :not_a_code: stays as it is