Browse Source

Added shtpl installer, path variables

master
dig 3 years ago
parent
commit
0dfc76bd1a
  1. 15
      shtpl/exemple/foo/other.shtpl
  2. 20
      shtpl/exemple/templates-path.shtpl
  3. 6
      shtpl/install
  4. 17
      shtpl/shtpl
  5. 0
      shtpl/tests/test.sh
  6. 0
      shtpl/tests/test.shtpl

15
shtpl/exemple/foo/other.shtpl

@ -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)

20
shtpl/exemple/templates-path.shtpl

@ -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

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

17
shtpl/shtpl

@ -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)\""

0
shtpl/test.sh → shtpl/tests/test.sh

0
shtpl/test.shtpl → shtpl/tests/test.shtpl

Loading…
Cancel
Save