2017 © Pedro PelĂĄez
 

craft-plugin inlin

A simple plugin for inlining stuff in your templates.

image

aelvan/inlin

A simple plugin for inlining stuff in your templates.

  • Wednesday, December 13, 2017
  • by aelvan
  • Repository
  • 1 Watchers
  • 59 Stars
  • 2,789 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 6 Forks
  • 4 Open issues
  • 2 Versions
  • 64 % Grown

The README.md

Inlin for Craft

A tiny plugin for inlining files in Craft templates., (*1)

This is the Craft 2.x version of Inlin, for the Craft 3.x version see the craft3 branch., (*2)

Usage

Use it like this:, (*3)

<script src="{{ craft.inlin.er('/build/svg/my.svg') | raw }}"></script>

Why? Sometimes it makes sense, performance or workflow wise, to inline resources instead of requesting them., (*4)

To include a remote file, pass in true as the second parameter:, (*5)

{{ craft.inlin.er('http://example.com/remote/path.svg', true) | raw }}

Warning

Understand that inserting filedata in your templates, especially when passing it through Twig's raw filter, is a potential security risk. And the path is relative to your document root, so the path could point to a file anywhere on your server. Make sure you never, ever let a third party control what is inserted. In case you're thinking "meh", insert this into your template:, (*6)

{{ craft.inlin.er('/../craft/config/db.php') | raw }}

"With great power, comes great responsibility" -Voltaire, (*7)

Configuration

Inlin needs to know the public document root to know where your files are located. By default Inlin will use $_SERVER['DOCUMENT_ROOT'], but on some server configurations this is not the correct path. You can configure the path by setting the inlinPublicRoot setting in your config file (usually found in /craft/config/general.php), (*8)

Example

'inlinPublicRoot' => '/path/to/website/public/',

Changelog

Version 1.1

  • Added ability to pull remote files

Version 1.0

  • Initial release

The Versions

13/12 2017

dev-craft3

dev-craft3

A simple plugin for inlining stuff in your templates.

  Sources   Download

MIT

The Requires

 

inline cms svg craftcms craft-plugin craft inlining criticalcss

10/08 2017

2.0.0

2.0.0.0

A simple plugin for inlining stuff in your templates.

  Sources   Download

MIT

The Requires

 

inline cms svg craftcms craft-plugin craft inlining criticalcss