-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from davist11/master
Add ability to pull in remote files
- Loading branch information
Showing
6 changed files
with
53 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,51 @@ | ||
Inlin for Craft | ||
=========== | ||
|
||
A tiny plugin for inlining files in Craft templates. | ||
A tiny plugin for inlining files in Craft templates. | ||
|
||
|
||
Usage | ||
--- | ||
Use it like this: | ||
|
||
<script src="{{ craft.inlin.er('/build/svg/my.svg') | raw }}"></script> | ||
|
||
Why? [Sometimes](http://css-tricks.com/svg-sprites-use-better-icon-fonts/) it | ||
[makes sense](http://www.yottaa.com/blog/bid/306224/Inlining-for-Performance-When-to-Let-the-Cache-Go), | ||
<script src="{{ craft.inlin.er('/build/svg/my.svg') | raw }}"></script> | ||
|
||
Why? [Sometimes](http://css-tricks.com/svg-sprites-use-better-icon-fonts/) it | ||
[makes sense](http://www.yottaa.com/blog/bid/306224/Inlining-for-Performance-When-to-Let-the-Cache-Go), | ||
performance or workflow wise, to inline resources instead of requesting them. | ||
|
||
To include a remote file, pass in true as the second parameter: | ||
|
||
{{ 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.** | ||
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: | ||
|
||
{{ craft.inlin.er('/../craft/config/db.php') | raw }} | ||
|
||
*"With great power, comes great responsibility" -Voltaire* | ||
*"With great power, comes great responsibility" -Voltaire* | ||
|
||
|
||
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 | ||
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) | ||
|
||
####Example | ||
|
||
'inlinPublicRoot' => '/path/to/website/public/', | ||
|
||
|
||
Changelog | ||
--- | ||
### Version 1.1 | ||
- Added ability to pull remote files | ||
|
||
### Version 1.0 | ||
- Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters