Skip to content

Instantly share code, notes, and snippets.

View hvdklauw's full-sized avatar
🏠
Working from home (mostly)

Harro van der Klauw hvdklauw

🏠
Working from home (mostly)
View GitHub Profile
@hvdklauw
hvdklauw / custom-table.blade.php
Created August 7, 2018 14:54
Custom Backpack table field that posts an actual array.
<!-- array input -->
<?php
$max = isset($field['max']) && (int) $field['max'] > 0 ? $field['max'] : -1;
$min = isset($field['min']) && (int) $field['min'] > 0 ? $field['min'] : -1;
$item_name = strtolower(isset($field['entity_singular']) && !empty($field['entity_singular']) ? $field['entity_singular'] : $field['label']);
$items = old($field['name']) ? (old($field['name'])) : (isset($field['value']) ? ($field['value']) : (isset($field['default']) ? ($field['default']) : '' ));
// make sure not matter the attribute casting
@hvdklauw
hvdklauw / reblock.py
Created December 3, 2024 18:30
Template tag to rerender a block
from django import template
from django.template.loader import get_template
from django.template.loader_tags import BlockNode, ExtendsNode
register = template.Library()
@register.simple_tag(takes_context=True)
def reblock(context, block_name):
"""
Renders a specific block from the current template or its parent templates.