1
0
mirror of https://github.com/deadc0de6/dotdrop.git synced 2026-02-04 17:24:46 +00:00

clean header

This commit is contained in:
deadc0de6
2018-09-02 15:20:11 +02:00
parent c54ed51a02
commit 0d590e987a
2 changed files with 5 additions and 16 deletions

View File

@@ -654,29 +654,23 @@ These can then be used in any template with
Dotdrop is able to insert a header in the generated dotfiles. This allows
to remind anyone opening the file for editing that this file is managed by dotdrop.
The header provides additional information like the last update date/time and
dotdrop's version.
Here's an example of such an header:
Here's what it looks like:
```
This dotfile is managed using dotdrop v0.19.2 / last updated 2018-09-01 00:01
This dotfile is managed using dotdrop
```
Such a header can be automatically added using jinja2 directive:
The header can be automatically added using jinja2 directive:
```
{{@@ header() @@}}
```
Properly commenting the header in the dotfile is the responsability of the user
Properly commenting the header in templates is the responsability of the user
as jinja2 has no way of knowing what is the proper char(s) used for comments.
Either prepend the directive with the commenting char(s) used in the dotfile (for example `# {{@@ header() @@}}`)
or provide it as an argument `{{@@ header('# ') @@}}`. The result is equivalent.
Remember that when using the header, comparing dotfiles will notice changes as the
temporary version generated to compare with the local dotfile will have a different
date and time.
## Environment variables
It's possible to access environment variables inside the templates.

View File

@@ -9,7 +9,6 @@ import subprocess
import tempfile
import os
import shlex
import datetime
from shutil import rmtree
# local import
@@ -70,8 +69,4 @@ def samefile(path1, path2):
def header():
header = 'This dotfile is managed using dotdrop'
header += ' v{}'.format(VERSION)
now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M")
header += ' / last updated {}'.format(now)
return header
return 'This dotfile is managed using dotdrop'