1. Go to this page and download the library: Download brandaddition/module-svelte library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
brandaddition / module-svelte example snippets
declare(strict_types=1);
namespace Vendor\Module\ViewModel;
use Magento\Framework\View\Element\Block\ArgumentInterface;
class Example implements ArgumentInterface
{
/**
* @return string
**/
public function getMessage(): string
{
return 'Hello from Magento';
}
}
declare(strict_types=1);
namespace Vendor\Module\Model\PropResolver;
use BA\Svelte\Api\PropResolverInterface;
use Magento\Framework\View\Element\Template;
class ExamplePropResolver implements PropResolverInterface
{
public function resolve(string $propName, array $definition, Template $block): mixed
{
$value = $definition['value'] ?? null;
return is_string($value) ? strtoupper($value) : null;
}
}