Closed toonvandenbos closed 9 months ago
Je crois que j'ai un bug, il ne publie rien :
@voidgraphics il n'est pas configuré le TxtImg (le handle()
est vide, regarde dans src/Components/Publishers/TxtImg.php
), tu peux tester avec le WYSIWYG.
Je comprends pas ce qu'on demande ici 😅
Edit : J'ai compris, c'est juste un exemple pour montrer qu'on peut remplacer des tags dans le code
This PR adds the ability to publish pre-coded component files to a Laravel project.
In order to create a publishable component, one should simply create a new "Publisher" class inside
src/Components/Publishers
and implementWhitecube\LaravelPreset\Components\PublisherInterface
:Most of the heavy-lifting will be achieved inside the publisher's
handle()
method. For instance, it's a great place to prompt for additional component-specific information and configure the publishable files accordingly.The
handle()
method's main purpose is to collect and return the publishable files, that's why this PR provides aFile
class with several useful methods and features. First, you can choose to create aFile
instance using one of these methods:File::makeFromStub(string $destination, string $stub)
: useful when working with existing files ;File::make(string $destination, string $content, ?string $origin = null)
: useful when creating files from scratch.Most of the time,
File::makeFromStub
should be used in order to keep a clear commit history on the component's original files somewhere in this package'scomponents/[your-component]
directory.These
File
instances can be manipulated before publication with a few useful methods:$sassFile->replaceVariableValue('wysiwyg_width_columns', 10)
;$sassFile->replaceBemBase('wysiwyg', 'foo')
;$bladeFile->replaceBemBase('wysiwyg', 'foo')
;Of course, Laravel Prompts can be used anywhere inside a publisher's
handle()
method, which is useful for file configuration:More features could be added to the
File
classes, but I think this is already a good start for the few upcoming publishable components.