Source

shinypress / shinypress / images.py

Full commit
import os.path
from shinypress.jinja import env
from glob import glob

template = env.from_string(r"""
%% for filename in images %%
\begin{frame}
\begin{list}{}{%
\setlength{\leftmargin}{-1.5em}%
\setlength{\rightmargin}{-1.5em}%
}%
\item[]{\begin{center}
\includegraphics[width=\linewidth,height=\textheight-.25em,keepaspectratio]{<filename>}
\end{center}}
\end{list}
\end{frame}
%% endfor %%
""")

def render(directory):
    directory = os.path.abspath(directory)
    images = sorted(glob(os.path.join(directory, "*.jpg")))
    return (template.render(images=images), [])