Added shtpl installer, path variables

This commit is contained in:
dig 2019-03-02 21:12:33 +01:00
parent 9ce116ef89
commit 0dfc76bd1a
6 changed files with 55 additions and 3 deletions

15
shtpl/exemple/foo/other.shtpl Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/env shtpl
SHTPL path:
$__shtpl_path__
SHTPL dir:
$__shtpl_dir__
Current template path:
$__tpl_path__
Current template dir:
$__tpl_dir__
Current template filename:
$__tpl_name__
Current working dir:
$(pwd)

View File

@ -0,0 +1,20 @@
#!/usr/bin/env shtpl
SHTPL path:
$__shtpl_path__
SHTPL dir:
$__shtpl_dir__
Current template path:
$__tpl_path__
Current template dir:
$__tpl_dir__
Current template filename:
$__tpl_name__
Current working dir:
$(pwd)
Sub template
------------
$($__tpl_dir__/shtpl/B.shtpl)

6
shtpl/install Executable file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
from=$(pwd)/$(dirname "$0")
to=/usr/local/bin
cp $from/shtpl $to/shtpl

View File

@ -1,11 +1,22 @@
#!/bin/bash
# Utils
__shtpl_path__=$(realpath $0)
__shtpl_dir__=$(dirname $0)
__tpl_path__=$(realpath $1)
__tpl_name__=$(basename $__tpl_path__)
__tpl_dir__=$(dirname $__tpl_path__)
# Execution
eval "echo \"$(cat $1 | sed '
# Suppress hashbang
1{ /#\!.*shtpl/ d }
# Excape quotes
s/"/\\"/g
')\""
#eval "echo \"$(perl -p -e 's/"/\\"/g' $1)\""