Skip to content

Conversation

@user-named-void
Copy link
Contributor

A Doc_date test failed because it validates the date.now.year.

@xoofx
Copy link
Member

xoofx commented Mar 5, 2025

The doc is automatically generated from

/// <summary>
/// Returns a datetime object of the current time, including the hour, minutes, seconds and milliseconds.
/// </summary>
/// <remarks>
/// ```scriban-html
/// {{ date.now.year }}
/// ```
/// ```html
/// 2024
/// ```
/// </remarks>
public static DateTime Now() => DateTime.Now;

You need then to rerun Scriban.DocGen to generate the associated file.

@user-named-void
Copy link
Contributor Author

@xoofx thank you for pointing me in the right direction, the remarks are updated and if have ran Sriban.DocGen

@xoofx
Copy link
Member

xoofx commented Mar 6, 2025

Not your fault (probably a previous PR), but it seems the JSON version in the code is invalid and has invalid spaces:

/// <summary>
/// Converts the json to a scriban value. Object, Array, string, etc.
/// </summary>
/// <param name="context">The template context</param>
/// <param name="json">The json to deserialize.</param>
/// <returns>Returns the scriban value</returns>
/// <remarks>
/// ```scriban-html
/// {{
/// obj = `{ "foo": 123 }` | object.from_json
/// obj.foo
/// }}
/// ```
/// ```html
/// 123
/// ```
/// </remarks>
public static object FromJson(TemplateContext context, string json)
{
return JsonSerializer.Deserialize<JsonElement>(json).ToScriban();
}
/// <summary>
/// Converts the scriban value to JSON
/// </summary>
/// <param name="context">The template context</param>
/// <param name="value">The input object.</param>
/// <returns>A JSON representation of the value</returns>
/// <remarks>
/// ```scriban-html
/// {{ { foo: "bar", baz: [1, 2, 3] } | object.to_json }}
/// {{ true | object.to_json }}
/// {{ null | object.to_json }}
/// ```
/// ```html
/// { "foo": "bar", "baz": [1, 2, 3] }
/// true
/// null
/// ```
/// </remarks>
public static string ToJson(TemplateContext context, object value)

If you can correct it as well, that would be great, thank you!

@xoofx
Copy link
Member

xoofx commented Mar 6, 2025

Basically it should be:

 /// ```html 
 /// {"foo":"bar","baz":[1, 2, 3]} 
 /// true 
 /// null 
 /// ``` 
 /// </remarks> 
 public static string ToJson(TemplateContext context, object value) 

@user-named-void user-named-void changed the title Doc_date test failed because of new year Fix DateTime and Object tests Mar 6, 2025
@user-named-void
Copy link
Contributor Author

Yes, i fixed the object.to_json test, all test are now succesfull on my system

@xoofx xoofx added the bug label Mar 6, 2025
@xoofx xoofx merged commit 9140c2a into scriban:master Mar 6, 2025
1 check passed
@xoofx
Copy link
Member

xoofx commented Mar 6, 2025

Thank you for the quick fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants