Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for trim input prefix and set the prefix to the ass…
…et name. Detail: the tree (~/go/src/github.com/user/project): ./ ./assets/ templates/admin/template.tmpl static/js/vendors/jquery.min.js ./.xbinputs.yml contents of ./.xbinputs.yml: sources: - path: assets prefix: _ recursive: true ns: "(2)/$PKG/.." The new translate process "[C=(2)]/[B=$PKG]/[A=..]": 1. the Variables: - BASE_DIR: `assets` - BASE_DIR ABS PATH: `~/go/src/github.com/user/project/assets` - ASSETS_PACKAGE (inside `$GOPATH/src`): `github.com/user/project/assets` 2. translate the namespace: 1. initial value: `(2)/$PKG/..` 2. replaces `$PKG` to ASSETS_PACKAGE: `(2)/github.com/user/project/assets/..` 3. clean it: `(2)/github.com/user/project` 4. detect namespace DIR_REPLACES_COUNT: `(2)` -> set DIR_REPLACES_COUNT to `2` 3. walk assets: 1. `templates/admin/template.tmpl`: 1. detect DIR_REPLACES_COUNT (as `2`) values (from root path): two values: - first value `templates` - second value `admin` - result: `templates/admin` 2. remove DIR_REPLACES_COUNT match in template path: - current template path is `templates/admin/template.tmpl` - now template path is: `template.tmpl` 3. replaces DIR_REPLACES_COUNT match in namespace: - current namespace is `(2)/github.com/user/project` - replaces `(2)` to `templates/admin` - result: `templates/admin/github.com/user/project` 3. make ASSET_NAME: join namespace and template path: - namespace is `templates/admin/github.com/user/project` - template path is `template.tmpl` - ASSET_NAME is `templates/admin/github.com/user/project/template.tmpl` 2. `static/js/vendors/jquery.min.js`: 1. detect DIR_REPLACES_COUNT (as `2`) values (from root path): two values: - first value `static` - second value `js` - result: `static/js` 2. remove DIR_REPLACES_COUNT match in template path: - current template path is `static/js/vendors/jquery.min.js` - now template path is: `vendors/jquery.min.js` 3. replaces DIR_REPLACES_COUNT match in namespace: - current namespace is `(2)/github.com/user/project` - replaces `(2)` to `static/js` - result: `static/js/github.com/user/project` 3. make ASSET_NAME: join namespace and template path: - namespace is `static/js/github.com/user/project` - template path is `vendors/jquery.min.js` - ASSET_NAME is `static/js/github.com/user/project/jquery.min.js` 4. the assets names: - `templates/admin/template.tmpl` -> `templates/admin/github.com/user/project/template.tmpl` - `static/js/vendors/jquery.min.js` -> `static/js/github.com/user/project/jquery.min.js`
- Loading branch information