File tree Expand file tree Collapse file tree 4 files changed +50
-2
lines changed Expand file tree Collapse file tree 4 files changed +50
-2
lines changed Original file line number Diff line number Diff line change 2424 "sempro/phpunit-pretty-print" : " ^1.0"
2525 },
2626 "autoload" : {
27+ "files" : [
28+ " src/helpers.php"
29+ ],
2730 "psr-4" : {
2831 "Vedmant\\ LaravelShortcodes\\ " : " src/"
2932 }
Original file line number Diff line number Diff line change 124124@shortcodes('[b]bold[/b]')
125125```
126126
127+ #### Render shortcodes with ` shortcodes() ` helper
128+
129+ ``` blade
130+ <div class="some-block">
131+ {{ shortcodes('[b]bold[/b]') }}
132+ </div>
133+ ```
127134
128135### Shared attributes
129136
@@ -182,9 +189,8 @@ $ vendor/bin/phpunit
182189
183190## TODO
184191
185- 1 . shortcodes() helper
186- 1 . Add Debugbar integration tests
1871921 . Shortcodes help data generator
193+ 1 . Add Debugbar integration tests
1881941 . Casting attributes (int, bool, array (comma separated))
1891951 . Add basic bootstrap shortcodes set
1901961 . Add commands to generate a shortcode view, generate view by default with make: shortcode
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ use Illuminate \Support \HtmlString ;
4+
5+ if (! function_exists ('shortcodes ' )) {
6+
7+ /**
8+ * Render shortcodes
9+ *
10+ * @param string $string
11+ * @return string|HtmlString
12+ */
13+ function shortcodes ($ string )
14+ {
15+ return app ('shortcodes ' )->render ($ string );
16+ }
17+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace Vedmant \LaravelShortcodes \Tests \Unit ;
4+
5+ use Vedmant \LaravelShortcodes \Tests \Resources \BShortcode ;
6+ use Vedmant \LaravelShortcodes \Tests \TestCase ;
7+
8+ class HelpersTest extends TestCase
9+ {
10+ public function testFunction ()
11+ {
12+ $ this ->assertTrue (function_exists ('shortcodes ' ));
13+ }
14+
15+ public function testRenderWithHelper ()
16+ {
17+ $ this ->manager ->add ('b ' , BShortcode::class);
18+
19+ $ rendered = \shortcodes ('[b class="test"]Content[/b] ' );
20+ $ this ->assertEquals ("<b class= \"test \">Content</b> " , (string ) $ rendered );
21+ }
22+ }
You can’t perform that action at this time.
0 commit comments