Sha256: 76dded358abc5284257523af16fbd534ad18808000b4935363a525b76222ae85
Contents?: true
Size: 508 Bytes
Versions: 161
Compression:
Stored size: 508 Bytes
Contents
import { Controller } from '@hotwired/stimulus' export default class extends Controller { /** * Helper that parses the data attribute value to JSON */ getJsonAttribute(target, attribute, defaultValue = []) { let result = defaultValue try { result = JSON.parse(target.getAttribute(attribute)) } catch (error) {} return result } /** * Parses the attribute to boolean */ getBooleanAttribute(target, attribute) { return target.getAttribute(attribute) === '1' } }
Version data entries
161 entries across 161 versions & 1 rubygems