r4j4h / jspackager-html-tagger
Simple bare bones HTML tag generator for <script> and <link> tags
Installs: 43 753
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- psr/log: 1.0.0
Requires (Dev)
- phpunit/phpunit: ~4.2
This package is not auto-updated.
Last update: 2024-12-21 19:19:33 UTC
README
Tagger is a simple bare bones converter from file paths to <script>
and <link>
HTML tags written in PHP.
Installation
- Install Composer
composer require 'r4j4h/jspackager-html-tagger:1.0'
Usage
Basics
echo $tagger->getScriptTag('myscript.js');
<script type="text/javascript" src="myscript.js"></script>
echo $tagger->getStylesheetTag('myscript.css');
<link href="myscript.css" rel="stylesheet" type="text/css" />
Custom Media Type for Stylesheets
$tagger->setStylesheetMediaType('screen'); echo $tagger->getStylesheetTag('myscript.css');
<link href="myscript.css" media="screen" rel="stylesheet" type="text/css" />
Cache Bust
echo $tagger->getStylesheetTag('myscript.css', "text");
$this->assertEquals(
<link href="myscript.css?cb=text" rel="stylesheet" type="text/css" />
$tagger->cacheBustKey = 'mtime'; echo $tagger->getScriptTag('myscript.js', 123);
$this->assertEquals(
<script type="text/javascript" src="myscript.js?mtime=123"></script>
Extension Based Detection
echo $tagger->getTag('myscript.js'); echo $tagger->getTag('myscript.css');
<script type="text/javascript" src="myscript.js"></script> <link href="myscript.css" rel="stylesheet" type="text/css" />