Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: cleanup #74

Merged
merged 6 commits into from
Jul 5, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cleanup
  • Loading branch information
erdostw committed Jul 5, 2021
commit fa7ec13732008ae4bedd3318914419cad42a31a5
16 changes: 10 additions & 6 deletions src/stencil/model.clj
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
[stencil.eval :as eval]
[stencil.merger :as merger]
[stencil.model.numbering :as numbering]
[stencil.tree-postprocess :as tree-postprocess]
[stencil.types :refer [->FragmentInvoke]]
[stencil.util :refer :all]
[stencil.model.relations :as relations]
[stencil.model.common :refer :all]
[stencil.functions :refer [call-fn]]
[stencil.model.style :as style
:refer [expect-fragment-context! *current-styles*]]
[stencil.cleanup :as cleanup]))
Expand All @@ -38,9 +38,12 @@
;; set of already inserted fragment ids.
(def ^:private ^:dynamic *inserted-fragments* nil)

;; list of extra relations to be added after evaluating document
;; set of extra relations to be added after evaluating document
(def ^:private ^:dynamic *extra-files* nil)

(defn- add-extra-file! [m]
(assert (:new-id m))
(swap! *extra-files* conj m))

(defn- parse-content-types [^File cts]
(assert (.exists cts))
Expand Down Expand Up @@ -151,7 +154,8 @@
(update-in [:relations :parsed] (fnil into {})
(for [relation @*extra-files*
;; TODO: itt a path erteket ki neke tolteni valami jora.
:when (contains? fragment-names (:fragment-name relation))]
:when (or (not (contains? relation :fragment-name))
(contains? fragment-names (:fragment-name relation)))]
[(:new-id relation) relation]))

;; relation file will be rendered instead of copied
Expand Down Expand Up @@ -221,7 +225,7 @@
elem)))


(defmethod eval/eval-step :cmd/include [f local-data-map {frag-name :name}]
(defmethod eval/eval-step :cmd/include [_ local-data-map {frag-name :name}]
(assert (map? local-data-map))
(assert (string? frag-name))
(expect-fragment-context!
Expand All @@ -243,8 +247,8 @@
(map (partial relations/xml-rename-relation-ids relation-rename-map))
(map (partial style/xml-rename-style-ids style-ids-rename)))]
(swap! *inserted-fragments* conj frag-name)
(swap! *extra-files* into relation-ids-rename)
(run! add-extra-file! relation-ids-rename)
[{:text (->FragmentInvoke {:frag-evaled-parts evaled-parts})}])
(throw (ex-info "Did not find fragment for name!"
{:fragment-name frag-name
:all-fragment-names (set (keys *all-fragments*))})))))
:all-fragment-names (set (keys *all-fragments*))})))))