hpattern

Paolo Lucchesi, 2008

Il programma hpattern è un'utility per includere all'interno di uno o più file HTML il contenuto di un altro file, e aggiornare la parte inclusa se il file da cui questa proviene viene modificato. Questo risolve il problema della mancanza di un comando per includere un file HTML in un altro.

Istruzioni

Aggiungere nel file destination_file.html destinatario la riga
<!--#pattern file="file_to_include.htmh" -->
e di seguito la riga
<!--#endpattern -->

Creare o editare il file file_to_include.htmh contenente il frammento di html da includere

Lanciare il comando hpattern destination_file.html.

Tutto quello che nel file destination_file.html si trovava tra <!--#pattern file="file_to_include.htmh" --> e <!--#endpattern --> viene sostituito con il contenuto del file file_to_include.htmh. Per questo è fondamentale ricordarsi di aggiungere la riga <!--#endpattern --> se non si vuole che tutto il successivo contenuto del file venga rimosso.

Ovviamente è possibile usare il comando hpattern *.html per aggiornare tutti i file HTML all'interno di una directory, e/o lanciare il comando hpattern da file batch/script.

Esempio

Aprite con un editor il file example.html e osservate come parte del codice sia compresa tra <!--#pattern file="ex_menu.htmh" --> e <!--#endpattern -->. Chiudete il file.

Aprite e modificate a piacere il file ex_menu.htmh. Salvate e chiudete.

Lanciate il comando hpattern example.html.

Aprite nuovamente il file example.html e osservate il risultato.

Licenza e disclaimer

Questo programma è pubblico dominio; come tale può essere liberamente copiato, distribuito e modificato. Mantenere il nome dell'autore originario è gradito ma non necessario.

Questo programma è distribuito senza alcuna garanzia. L'autore non può essere ritenuto in alcun modo responsabile di eventuali danni provocati direttamente o indirettamente dall'uso proprio o improprio di questo programma.


hpattern

Paolo Lucchesi, 2008

The hpattern software is an utility to include in an HTML file the content of anothre file, and to updated the included part if the source file is updated. This helps about the missing HTML include command.

Instructions

Put this line
<!--#pattern file="file_to_include.htmh" -->
in the destination_file.html target file, then put this line
<!--#endpattern -->
below, in the same file.

Create or edit the file_to_include.htmh file, containing the snippet of html code that should be included.

Run the hpattern destination_file.html command.

In the destination_file.html file between <!--#pattern file="file_to_include.htmh" --> and <!--#endpattern --> is replaced by the content of the file_to_include.htmh file. So, always remember to put the <!--#endpattern --> line, otherwise all the subsequent code will be removed.

Obvioulsy, you can use the hpattern *.html command to update all the HTML files in a directory. Also you can launch hpattern from a batch/script file.

Example

With an editor open the example.html file and look at the code snippet between the <!--#pattern file="ex_menu.htmh" --> and the <!--#endpattern --> lines. Close the file.

Open and modify the ex_menu.htmh file as you like. Save and close.

Run the hpattern example.html command.

Open the example.html file again, and look at the result.

License and disclaimer

This software is public domani; it can be freely copied, distribuited and modified. Keepin the original author name is appreciated but not needed.

This program is provided "as is", without warranty of any kind, express or implied. In no event the author will be liable for any damage arising directly or undirectly from the proper or inproper use of this software.