-
-
Notifications
You must be signed in to change notification settings - Fork 359
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
PowerShell and PSCustomObject #540
Comments
Shouldn't it be more something like the following?
Not sure to follow why you would want to import all the metadatas of |
@xoofx I was going off this example in the docs:
Where the In PS,
is the equivalent of doing
in C#. |
Sorry, mixed the target object and the parameter:
The problem is that it looks like you are importing the wrong thing. The |
To access The confusing thing is that when I use Maybe the renderer fails to fetch the value correctly because NB: This is not a huge issue, since I have a function to perform a simple conversion from a |
They are not. Only properties should be imported. Because otherwise you have to modify your script to go through properties:
That's why I'm suggesting to pass It should be instead something like:
|
Ok, I think I've got it. I've tested it with a regular C# class and it worked as expected. The problem is that Without Scriban treating
This is a naive implementation, since it doesn't handle nested |
Hi!
I'm trying to use scriban in Windows PowerShell 5.1 and am having issues with rendering
PSCustomObject
objects.Using
hastable
andOrderedDictionary
works fine, e.g.:My problem is that
ConvertFrom-Json
cmdlet returns aPSCustomObject
and not a hashtable (that option is available in PS 6/7, but not in 5.1), and I'd like to use parsed JSON files as input to some of my templates.The trivial approach above does not work, which is expected, since
PSCustomObject
is not a dictionary/hashtable.Next, I tried the "import .NET object instance" approach:
$scriptObject.properties
listsfoo
as a member:$scriptObject.properties MemberType : NoteProperty IsSettable : True IsGettable : True Value : bar TypeNameOfValue : System.String Name : foo IsInstance : True
$context.CurrentGlobal
also looks ok:Am I doing something wrong here, or does scriban not handle
NoteProperty
members?Thank you!
The text was updated successfully, but these errors were encountered: