Skip to content

Instantly share code, notes, and snippets.

@k3ssen
k3ssen / FetchComponent.vue
Last active August 10, 2020 10:43
FetchComponent - fetch an url into a dynamic vue component
<template>
<component v-if="component" :is="component"></component>
</template>
<script>
export default {
data: () => ({
component: null,
}),
props: {
@k3ssen
k3ssen / AppControllerTrait.php
Created July 24, 2020 13:16
Symfony Router: object instead of id
<?php
declare(strict_types=1);
namespace App\Controller;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
trait AppControllerTrait
{
@k3ssen
k3ssen / App.vue
Last active December 31, 2019 17:27
TwigVueComponent
<template>
<component :is="vueComponent" @clickTitle="clickTitle"></component>
</template>
<script>
export default {
data: () => ({
vueComponent: typeof vue === 'undefined' ? { template: `<p>No vue component</p>` } : vue,
}),
methods: {
@k3ssen
k3ssen / EmbedParser.php
Last active July 28, 2018 15:10
Parser to replace the Twig_TokenParser_Embed to allow using content inside embed without block.
<?php
declare(strict_types=1);
namespace App\Twig;
use Twig\TokenParser\EmbedTokenParser;
class EmbedParser extends \Twig_TokenParser_Include
{
protected CONST TAG_NAME = 'embed';
@k3ssen
k3ssen / ComponentExtension.php
Last active April 29, 2018 19:09
Own implementation of the \Twig_TokenParser - similar to the \Twig_TokenParser_Embed, but with some extra features
<?php
declare(strict_types = 1);
namespace K3ssen\BaseAdminBundle\Twig;
class ComponentExtension extends \Twig_Extension
{
public function getTokenParsers()
{
// Example defining own component-tags