Sloths shipping with a lot of builtin useful helpers

HTML Assets Tag Helpers

views/my-view-script.html.php
The output is:

Disable Caching Assets Tag

As you know, the assets tag might caching by the browser. For example, sometime you changes the javascript code, but you might need press Ctrl+F5 on Windows or Cmd+F5 on Mac to tell browser update your script code. Is is bad for end user, they don't know you was changes the script code. Solved that problem is very simple, just append the assert script source url with a increment parameter version number whenever you change the script code.

Commonly, I'm do that by this way: application/config/view.php

Changes v1 to v2, v3,.. whenever you change the script code.

And now you call asset tag helper like above, the output is:

Or if you want to directive config per assert by calling: setDisableCachingParam('v1')


The output now is:


For development mode, I recommend you to set the disable caching param value to time()


The output look like:

Escape Helper

views/my-view-script.php

output: <div>

FormatDateTime & FormatDate Helper

MailTo Helper

Partial & PartialLoop Helper

views/partial.html.php views/my-view-scripts.php routes/my-route.php Output:

Capture Helper

views/_layouts/default.html.php views/content.html.php routes/my-route.php Output:

Url Helper

Paginate Helper

$paginator = new \Sloths\Pagination\Paginator($adapter);

$adapter can be:

  • \Sloths\Pagination\DataAdapter\ArrayAdapter
  • \Sloths\Pagination\DataAdapter\DbSelect
  • \Sloths\Pagination\DataAdapter\ModelCollection
  • Array
  • \Sloths\Db\Sql\Select
  • \Sloths\Db\Model\Collection

routes/my-route.php views/posts/list.html.php Output:
  • post 35
  • post 36
  • post 37
  • post 38
  • post 39


comments powered by Disqus