Comments (3)
Unfortunately this isn't directly supported. It is close to being supported, but due to a bug it fails - I'll report that and fix it shortly.
The best I could do is fix the bug, then write this:
files: file_glob( "*.jpg*" )
----
This is a simple image-gallery:
<!-- tmpl_loop name='files' -->
<!-- tmpl_if name='width' -->
<img src= "<!-- tmpl_var name='file' -->" width="<!-- tmpl_var name='width' -->" height="<!-- tmpl_var name='height' -->">
<!-- /tmpl_if -->
<!-- tmpl_if name='contents' -->
<p><!-- tmpl_var name='contents' --></p>
<!-- /tmpl_if -->
<!-- /tmpl_loop -->
This relies upon the FileGlob.pm
behaviour which I'd forgotten about:
- If a glob matches an image and you have Image::Size available then the variables
width
andheight
will be populated.- Here we use that to wrap an "if" around the image.
- If the glob does not match an image, and does not match the templer suffix, then the contents are available as
content
- but this is a bug, becaues the same name is used in the layout.
* I've just updated the code to usecontents
instead.
The files here are:
deagol ~/x $ ls -1 input/
17635184_10212309877612942_91544094097573559_o.jpg
17635184_10212309877612942_91544094097573559_o.jpg.caption
18278724_10155384183372342_4594716052523220387_o.jpg
18278724_10155384183372342_4594716052523220387_o.jpg.caption
index.skx
So the glob here matches "*.jpg*
" which half the time is an image, and half the time is a caption.
from templer.
OK bug fixed - the example above should now work if you update to include the commit I just made, but this is a bit terrible, so you might prefer to write a plugin instead :)
from templer.
I might have a try at a plugin then, and if I can't make it work try the "terrible" way :)
Thanks for the rapid reply! I guess I'll close this as it seems a plugin is the "official" way to do it.
from templer.
Related Issues (19)
- `templer --manual` is broken.
- As Bruno said the code structure is confusing at times.
- Variables not replaced with correct value HOT 7
- File inclusion should have a search path.
- The file-hash plugin is bogus.
- Need a straightforward installation process. HOT 9
- Undeclared dependency on Test::Exception
- .htaccess files are not processed HOT 3
- Installation from CPAN fails HOT 3
- Output filename should come from the page. HOT 1
- `make standalone` is broken.
- Update our plugin-handlers.
- Release signature invalid HOT 18
- FileGlob makes content available as `content`.
- Pod::Find dependency not listed HOT 2
- We shouldn't only run from the top-level directory. HOT 1
- When using include files we don't rebuild if they change.
- It isn't possible to auto-generate pages / create virtual pages. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from templer.