#templating

N-gated Hacker Newsngate
2025-07-01

Ah, yes, yet another genius proposal to solve a problem no one knew they had: a 💫 "native" 💫 API! Because, clearly, the web development community hasn't had enough hand-wringing debates about what "declarative" means. 😂 Let's all gather 'round and stare in awe at the brilliance of the obvious! 🎉
justinfagnani.com/2025/06/30/w

Inautiloinautilo
2025-06-27


Declarative templating API proposal · “The time is right for a DOM templating API.” ilo.im/164yqf

_____

aaron ~# :blinkingcursor:neuroexception@infosec.exchange
2025-06-07

I came across the #Fail2Ban #docker image from #linuxserverio and thought to myself that it's finally time to set up Fail2Ban. I admit i never used it before and it was a bit difficult to add it to my #playbook as all of my #servers have different services and therefore different #logfile paths, but that's nothing #jinja #templating can't fix.

Now that i've got #Discord notifications for banned #IPs, it's time to work on actual #IPblocking. I also want to use the #IPComplaint and #AbuseIPDB actions as i really like the idea of reporting abuse (even though i have no idea how effective that may be).

I may also want to replace the discord #webhook with #email notifications later as that's mostly the reason i've set up a #mailserver ( #stalwart ) in the first place.

I mean, most of my services are only accessible from #tailscale or my #homenetwork, but since #Ansible makes it so much easier to apply higher standards, i just can't resist. My #homelab is changing every day and i think setting up additional #security, even though i don't need it yet, is never a bad idea.

#networking #badactors #firewall #automation #linux #selfhosting #homeserver

2025-05-22

GreatBlogs – Ressourcen-Optimierung, RSS und Co.

In GreatBlogs – Technik-Umschwung am Frontend habe ich schon Änderungen an der Technologie-Auswahl angekündigt. Ein Teil dessen wurde mittlerweile auch umgesetzt. Schauen wir uns die Änderungen im Detail an.

Feed-Generierung

Der Beitrags-Feed wurde im ersten Schritt mit Vue.js realisiert. Das ist nett, aber im Grunde ergibt das dann doch bei jedem Aufrung eine Query gegen die Datenbank. Nun ist es nicht so relevant, auf Sekundenbasis neue Beiträge tatsächlich auch zu listen. Die Entscheidung, den Feed-Reader zu generieren und statisch auszuliefern, war daher sehr einfach.

Go bietet eine Templating-Engine an, die für diese Zwecke perfekt ist. Also habe ich Templates und Styles entworfen und per Go hole ich die relevanten Daten, jage sie durch die Templating-Engine und fertig ist das Ergebnis.

Da ohnehin alle 30 Minuten per Cronjob die registrierten Feeds aktualisiert wird, wird im Zuge dessen auch die Feed-Seite im Anschluss neu generiert.

Blogger Auflistung

In dieselbe Kerbe schlägt die neue Blogger-Auflistung. Diese zeigt alle registrierten Blogs an. Da sich diese noch seltener ändert, reicht eine Aktualisierung einmal am Tag. Auch dies wird über einen Cronjob durchgeführt.

RSS-Feeds

Wie im Screenshot oben zu sehen ist, werden mittlerweile auch RSS-Feeds angeboten. Hierfür gibt es eine praktische Go-Bibliothek: Gorilla Feeds.

Mit dieser Bibliothek können Atam bzw. RSS 2.0 Feeds sehr einfach erzeugt werden. Die Einbindung von Feeds ist damit ein Kinderspiel.

Hilfsmittel

Es gibt ja neben der technischen Aspekte weitere Themen zu bedienen: Usability, Accessability, Performance und natürlich auch IT-Themen. Das Einrichten und Konfigurieren von Cronjobs oder des Webservers zum Beispiel. Hier ein paar Links zu hilfreichen Webseiten:

#golang #GreatBlogs #RSS #templating

Screenshot von https://read.greatblogs.org mit links einer Auswahl an Themen und rechts der Auflistung von Beiträgen.
2025-05-16

GreatBlogs – Technik-Umschwung am Frontend

Es tut sich was bei GreatBlogs. Ich hatte ja im Beitrag GreatBlogs – Projekt und Technik geschrieben, dass ich großteils einen neuen Dev-Stack einsetze. Wie das dann so ist, kann sich sehr schnell etwas daran ändern und das wird es auch. Den Grund und noch weitere Themen gibt es in diesem Beitrag.

Statische Seiten brauchen weniger Ressourcen

Er war doch schon nett, der Gedanke, ein neues JavaScript-UI-Framework zu verwenden. Bei genauerer Überlegung, nach etwas Einarbeitungszeit und auch einigen Gesprächen bin ich nun an dem Punkt angelangt, dass ich das nicht brauche.

Vielmehr möchte ich auf möglichst viel JavaScript verzichten. Ein Großteil der Seiten soll auch ohne JavaScript auskommen können. Welche Gründe sprechen dafür?

  • Geringerer Ressourcenverbrauch
  • Läuft auch bei ausgeschaltenem JavaScript
  • Besseres Caching
  • Geringere Komplexität

Als Beispiel ist der Artikel-Feed zu nennen. Dieser zeigt, bis wieder neue Artikel verfügbar sind, immer dieselben Informationen an. Sie müssen nicht immer wieder aufs Neue aus der Datenbank geholt werden. Mit einer Templating Engine lässt sich die Feedseite bei neuen Artikeln einmal generieren. Weitere Zugriffe auf die Datenbank sind nicht notwendig. Mit zunehmender Besucheranzahl macht sich das bemerkbar.

Da im Hintergrund in regelmäßigen Abständen eine Artikelabfrage läuft, ist auch ein entsprechender Triggerpunkt vorhanden.

Entsprechend wurde der Feed nun auch umgebaut.

Go bietet bereits in der Standardbibliothek eine Template-Engine an, mit der sehr schnell und einfach HTML-Seiten (aber auch normale Text-Dateien) generiert werden können.

Das Ergebnis läuft ab sofort unter read.greatblogs.org. Noch setzt der Kategorie-Filter auf JavaScript, aber auch dieser wird in Bälde ersetzt.

Die nächsten technischen Schritte?

search.greatblogs.org läuft nun schon noch mit der Vue.js-App, aber auch hier wird es bald zu Änderungen kommen. Und dann geht es langsam aber sicher in Richtung Suchmaschine. Vorher gibt es noch ein paar Features für den Feed, aber dann geht es ans Eingemachte.

Bisherige Learnings?

Von Zeit zu Zeit ist es gut, sich in einen gänzlich neuen Tech-Stack zu werfen. Man lernt so unheimlich viel. Hier ein kurzer Ausschnitt:

  • Golang: WebAPI, Templating, Datenbankzugriffe
  • Linux Administration: Services, Automatisierung, Metriken, Logging
  • PostgreSQL: Administration, Backup

Auch wenn einige Dinge vorher schon bekannt waren: Es ist die Anwendung, die Herausforderung an der man wächst. Ein großes Stichwort ist auch Automatisierung. Das nimmt unheimlich viel (dumpfe) Arbeit ab und hilft zudem Fehler zu vermeiden.

Ich bin mir sicher, da kommt noch Vieles hinzu …

#golang #templating

Vincent Agnanovinyll
2025-04-14

LegoJs v1.9.0 is out with more simplicity and more modern to write  🚀

github.com/Polight/lego/pull/3

Documentation will follow.

Inautiloinautilo
2025-03-27


The case for “old school” CSS · Beyond “this(my) way is the best way.” ilo.im/162za1

_____

2025-03-19

Abivia Penknife, a small template engine inspired by Blade. Requires PHP 8.4. Because everyone needs Yet Another Template Engine, right? Well I did, and I'm sharing it. This tiny little thing clocks in under 300 LOC and has no dependencies.

github.com/abivia/penknife

#php #foss #templating

pihpi quando javascritto le stringhe fanno ciao!

Questa sera sono un po’ a caso impegnata in della magica programmazione, che ripulisce la mente e forse purifica l’animo, avendo come effetto collaterale anche quello di far avere al mondo nuovi programmini e progettini… Ed ho appena cacciato fuori un’idea assurda, talmente esoterica ma allo stesso tempo semplice che potrebbe essere forse illegale (ma io la userò comunque, in barba alla lobby del codice pulito). 🐒

Per motivi che ancora non so se andranno a segno, voglio poter fare templating HTML con la stessa sintassi sia da JavaScript che PHP, su stringhe che alla fine sono relativamente semplici, e quindi non ho voglia di aumentare la complessità di entrambi i programmi con librerie di templating particolari per una simile scemenza — e, volendo veramente mantenere la semplicità, voglio che siano in ogni caso normali funzioni del linguaggio a fare le formattazioni, e con la loro sintassi di interpolazione di stringhe, altrimenti l’editor poi non mi da i colori belli e mi viene mal di testa… 🤯

Aggiungiamoci anche il fatto che, per motivi che non mi metto a spiegare, l’unica opzione che davvero posso usare in un caso del genere per JavaScript lato client (HTML5) è uno <script> con dentro funzioni che fanno tipo function coso (id, dentro) { return `<div data-coso="${id}">${dentro}</div>` }… Ed ecco che la soluzione logica su cosa fare in PHP è tanto invisibile quanto precisamente sotto i miei occhi, tanto inappropriata quando calzante a pennello:

function js2php ( $zorp ) { // 😈  $zorp = str_replace( '`', '\'', $zorp );  $zorp = str_replace( '}<', '.\'<', $zorp );  $zorp = str_replace( '}"', '.\'"', $zorp );  $zorp = str_replace( '>${', '>\'.', $zorp );  $zorp = str_replace( '"${', '"\'.', $zorp );  return $zorp; // 💥}

E quindi, tipo, io eval(js2php(file_get_contents('templating.js')));, e poi da PHP chiamo le funzioni di templating esattamente come farei da JavaScript, quindi in questo caso coso(42, '<img src="cacca.jpg">');!!! Funziona talmente bene che davvero non comprendo come mai la mia qui definita funzione js2php non faccia parte della libreria standard di PHP; anche se, doverosa precisazione, per funzionare così (e rimanere compatibile con JavaScript) la mia funzione coso dovrebbe essere riscritta così: function coso ($id, $dentro) { return `<div data-coso="${$id}">${$dentro}</div>`; }. 😳

Quello che la mia funzione molto grezza fa è modificare giusto quel poco della sintassi JavaScript che non è in comune con PHP, per farla diventare tale, e quindi poter essere poi valutata dall’interprete; il coso di esempio, passandoci dentro, diventa infatti così: function coso ($id, $dentro) { return '<div data-coso="'.$id.'">'.$dentro.'</div>'; }. (L’esercizio sfizioso di commentare sotto questo post che questa soluzione non deve mai essere usata per gestire input non sicuro, visto che usa eval, è lasciato ai lettori; il mio caso d’uso è sicuro.) 💉

Bonus: per evitare di avere funzioni vaganti come proiettili nello scope di esecuzione, si possono ovviamente dichiarare le funzioni dentro una hashmap… la sintassi di creazione è diversa tra PHP e JavaScript, ma basta creare una funzione con lo stesso nome che su PHP fa return []; e su JS return {}, poi l’assegnazione è uguale su tutti e due i linguaggi: map['coso'] = function(...){...};. Insomma, chiamatemi pure imperatrice del riciclo, come scrivo codice monnezza pur di ottimizzare la scrittura dello stesso!!! 💩

#hack #HTML #PHP #programmazione #templating

2025-02-11

Donno about you guys but it sure is nice not to have to try and decipher the clusterfuck-like syntax of Hugo’s Go-based templating engine anymore…

The code on the left is Kitten¹, on the right is Hugo².

Kitten’s ‘template engine’ is just JavaScript tagged template strings.

(I’m porting the Small Technology Foundation web site³ from Site.js⁴ to Kitten, and in the process from being a Hugo-based static site to a dynamic one with a nice little admin panel I’m making to make it trivially easy to add new news items, events, and videos.)

¹ kitten.small-web.org
² gohugo.io
³ small-tech.org
sitejs.org

#Kitten #SmallWeb #SmallTech #Hugo #JavaScript #Go #web #dev #NodeJS #templating

Screenshot of split terminal window showing the sample template in Kitten (on the left, as a JavaScript tagged template string) and on the right in Hugo’s Go-based templating system.

Partial code comparison:

Kitten:

      <if ${db.news.posts.length > 0}>
        <then>
          <ul class='posts-list'>
          ${db.news.posts.map(post => kitten.html`
            <li>
              <h2 class='p-name'>${post.title}</h2>
              <div class='entry-meta'>
                <p>Posted: ${post.date} by ${post.author.name} on <a href='${post.author.siteLink}'>${post.author.siteName}</a>
              </div>
              <blockquote class='summary'>
                ${[kitten.md.render(post.summary)]}
              </blockquote>
            
Hugo:

	{{ $section := where .Site.RegularPages "Section" .Section }}
	<ul class='posts-list'>
		{{ range $section }}
			<li>
				<h2 class='p-name'>
					{{ .Title }}
				</h2>
				<div class='entry-meta'><p>Posted: <time datetime='{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}'>
					{{ .Date.Format "2" | humanize }} {{ .Date.Format "January, 2006" }}
					</time> {{ with .Params.author }}by {{ . }} {{end}}on <a href='{{ .Params.SourceURL }}'>{{ .Params.SourceName }}</a></p></div>
				<blockquote class='summary'>
					<p>{{ .Summary }}</p>
				</blockquote>
🧿🪬🍄🌈🎮💻🚲🥓🎃💀🏴🛻🇺🇸schizanon
2024-09-20

I know everyone's into Eleventy these days but I dislike it. It reminds me of WebPack; too configuration heavy.

I always liked but they took too long getting to v2 and now nobody ever talks about it.

Are there any other tools I should checkout?

I mainly just want , but I'd like to avoid template languages like Mustache and Liquid for PTSD reasons.

Bonus points if it I can use the same files in the browser.

2024-08-07

📝 Latte: One Line and Localization Done for You

Good news for all developers using Latte: the new version brings significant improvements in localization. Let's see how these updates can make your work easier and save you time.

blog.nette.org/en/latte-one-li

#php #nettefw #programming #webdev #dev #latte #templating #localization #l10n

2024-07-25

I’ve started to collect my knowledge on templating and how to recognize different templating laguages: https://slatecave.net/notebook/templating/

#templating

2024-07-10

🥳 Latte 3.0.17 was released!

✅ supports PHP 8.4
📌 supports locale in some filters
✨ ... and more!

github.com/nette/latte/release
nette.org/en/releases
latte.nette.org/

#nettefw #latte #programming #webdev #templating #php #security

2024-05-26

Thunderbird Auto Config Server (TACS)

На хабре уже были статьи по настройке почтового клиента Thunderbird, с подробным разбором его возможностей и деталей настроек, а поиск по сети выдаёт множество блогов с продублированной информацией о самых базовых его возможностях. Каждый из авторов решал настройку почты своим путём, используя разные языки и подходы. Моя цель - попытаться унифицировать это, избавиться от самописных скриптов, предоставив готовый сервер-шаблонизатор для выдачи настроек по запросу почтового клиента.

habr.com/ru/articles/812879/

#thunderbird #autoconfig #templating #автоконфигурация #почтовый_клиент #шаблонизация

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst