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

Custom tag support? #27

Open
jeroenvandijk opened this issue Oct 3, 2018 · 2 comments
Open

Custom tag support? #27

jeroenvandijk opened this issue Oct 3, 2018 · 2 comments

Comments

@jeroenvandijk
Copy link

jeroenvandijk commented Oct 3, 2018

Hi Owain,

Thank you for this project. At the moment I'm using it to generate YAML strings in Cloudformation templates. I would like to use it to read external Cloudformation templates as well. Unfortunately these templates have custom tags [1]. I've tried some hackery to get this working, but no luck so far. Do you have the intention to support custom tags? Or maybe you already have some direction how I could add this functionality?

Thanks,
Jeroen

[1] https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-sub.html#intrinsic-function-reference-sub-syntax.yaml

@tpot
Copy link

tpot commented Jul 2, 2019

Jeroen, I successfully parsed a CF template by using the :constructor keyword param as mentioned in the current README:

(let [template-file (first args)
      template-yaml (yaml/parse-string (slurp template-file) :constructor yaml.reader/passthrough-constructor)]
   (println template-yaml)))

@jeroenvandijk
Copy link
Author

@tpot Thanks for the feedback. I think I have tried the passthrough-constructor before. Unfortunately it removes the necessary information (or maybe I'm missing another way to use it):

➜  ~ clj -Sdeps '{:deps {io.forward/yaml {:mvn/version "1.0.9"}}}'
Clojure 1.10.0
user=>  (require '[yaml.core :as yaml])
nil
user=> (yaml/parse-string "Fn::Sub:
  - String
  - { Var1Name: Var1Value, Var2Name: Var2Value }" :constructor yaml.reader/passthrough-constructor)
#ordered/map ([:Fn::Sub ["String" #ordered/map ([:Var1Name "Var1Value"] [:Var2Name "Var2Value"])]])
user=>
(yaml/parse-string "!Sub
  - String
  - { Var1Name: Var1Value, Var2Name: Var2Value }" :constructor yaml.reader/passthrough-constructor)
["String" #ordered/map ([:Var1Name "Var1Value"] [:Var2Name "Var2Value"])]

Ideally the !Sub tag would be added somewhere so this (essential) information isn't lost.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants