diff --git a/composer.json b/composer.json index 8424851..fa35bf3 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,9 @@ "sempro/phpunit-pretty-print": "^1.0" }, "autoload": { + "files": [ + "src/helpers.php" + ], "psr-4": { "Vedmant\\LaravelShortcodes\\": "src/" } diff --git a/readme.md b/readme.md index 79b0de1..bb78844 100644 --- a/readme.md +++ b/readme.md @@ -124,6 +124,13 @@ Or @shortcodes('[b]bold[/b]') ``` +#### Render shortcodes with `shortcodes()` helper + +```blade +
+ {{ shortcodes('[b]bold[/b]') }} +
+``` ### Shared attributes @@ -182,9 +189,8 @@ $ vendor/bin/phpunit ## TODO -1. shortcodes() helper -1. Add Debugbar integration tests 1. Shortcodes help data generator +1. Add Debugbar integration tests 1. Casting attributes (int, bool, array (comma separated)) 1. Add basic bootstrap shortcodes set 1. Add commands to generate a shortcode view, generate view by default with make:shortcode diff --git a/src/helpers.php b/src/helpers.php new file mode 100644 index 0000000..4156174 --- /dev/null +++ b/src/helpers.php @@ -0,0 +1,17 @@ +render($string); + } +} diff --git a/tests/Unit/HelpersTest.php b/tests/Unit/HelpersTest.php new file mode 100644 index 0000000..8500d78 --- /dev/null +++ b/tests/Unit/HelpersTest.php @@ -0,0 +1,22 @@ +assertTrue(function_exists('shortcodes')); + } + + public function testRenderWithHelper() + { + $this->manager->add('b', BShortcode::class); + + $rendered = \shortcodes('[b class="test"]Content[/b]'); + $this->assertEquals("Content", (string) $rendered); + } +}