diff --git a/jrnl/plugins/meta.py b/jrnl/plugins/meta.py index 3cbff1ec..8108a936 100644 --- a/jrnl/plugins/meta.py +++ b/jrnl/plugins/meta.py @@ -9,8 +9,6 @@ import jrnl.contrib.importer import jrnl.plugins.exporter import jrnl.plugins.importer -from .template_exporter import __all__ as template_exporters - __exporters_builtin = list( pkgutil.iter_modules( jrnl.plugins.exporter.__path__, jrnl.plugins.exporter.__name__ + "." @@ -43,9 +41,6 @@ __exporter_types_contrib = { for plugin in __exporters_contrib for name in importlib.import_module(plugin.name).Exporter.names } -__exporter_types_template = { - name: plugin for plugin in template_exporters for name in plugin.names -} __importer_types_builtin = { @@ -62,7 +57,6 @@ __importer_types_contrib = { __exporter_types = { **__exporter_types_builtin, **__exporter_types_contrib, - **__exporter_types_template, } __importer_types = {**__importer_types_builtin, **__importer_types_contrib} diff --git a/jrnl/plugins/template_exporter.py b/jrnl/plugins/template_exporter.py deleted file mode 100644 index 4e6adfc0..00000000 --- a/jrnl/plugins/template_exporter.py +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env python -# encoding: utf-8 -# Copyright (C) 2012-2021 jrnl contributors -# License: https://www.gnu.org/licenses/gpl-3.0.html - -from glob import glob -import os - -from jrnl.plugins.template import Template -from jrnl.plugins.exporter.text_exporter import Exporter as TextExporter - - -class GenericTemplateExporter(TextExporter): - """This Exporter can convert entries and journals into text files.""" - - @classmethod - def export_entry(cls, entry): - """Returns a string representation of a single entry.""" - vars = {"entry": entry, "tags": entry.tags} - return cls.template.render_block("entry", **vars) - - @classmethod - def export_journal(cls, journal): - """Returns a string representation of an entire journal.""" - vars = {"journal": journal, "entries": journal.entries, "tags": journal.tags} - return cls.template.render_block("journal", **vars) - - -def __exporter_from_file(template_file): - """Create a template class from a file""" - name = os.path.basename(template_file).replace(".template", "") - template = Template.from_file(template_file) - return type( - str(f"{name.title()}TemplateExporter"), - (GenericTemplateExporter,), - {"names": [name], "extension": template.extension, "template": template}, - ) - - -__all__ = [] - -# Factory pattern to create Exporter classes for all available templates -for template_file in glob("jrnl/templates/*.template"): - __all__.append(__exporter_from_file(template_file)) diff --git a/jrnl/templates/sample.template b/jrnl/templates/sample.template deleted file mode 100644 index 983d6af3..00000000 --- a/jrnl/templates/sample.template +++ /dev/null @@ -1,18 +0,0 @@ ---- -extension: txt ---- - -{% block journal %} -{% for entry in entries %} -{% include entry %} -{% endfor %} - -{% endblock %} - -{% block entry %} -{{ entry.title }} -{{ "-" * len(entry.title) }} - -{{ entry.body }} - -{% endblock %}