- Newest
- Most votes
- Most comments
Please, please, Amazon, implement velocimacros! It would make so many things so much easier. Otherwise, if I want to define a custom function, I have to instead use #evaluate or #define which is really inconvenient and doesn't provide the same level of functionality.
Just coming back to say I'm building another endpoint on Dynamo, and I still can't use macros.
This is leading to me having to write smelly code.
SORT IT OUT AWS!!!!!
Another +1 to the ability to support Macros in VTL mappings.
Another option would be to make/enable a VLT tool/util method to change the Low level DynamoDB Response/Requests to Plain JSON the same way the DocumentClient Does in the SDKs or you can in the Console when you do create Item. This really would be a significant usability improvement.
Another +1 to the ability to support Macros in VTL mappings
Please add this feature 🙏
I second the call for better usability for the templates. Velocity is not a great choice, but since its there feature parity with Velocity 1.7 would be nice. Also, I ended up running Velocity in my test suite, but since the features don't match those tests will be non-conclusive.
Edited by: torgeir on Nov 4, 2019 10:37 AM
Still in 2021, waiting for Velocity Macros in AWS API Gateway.
In case any one wondering, this is the macro I want to run; https://gist.github.com/narenranjit/1672345#gistcomment-2096494
#set ( $obj = '' ) ## dummy object
#set ( $int_class = $obj.class.forName('java.lang.Number') )
#set ( $bool_class = $obj.class.forName('java.lang.Boolean') )
#set ( $string_class = $obj.class.forName('java.lang.String') )
#set ( $map_class = $obj.class.forName('java.util.Map') )
#set ( $list_class = $obj.class.forName('java.util.List') )
#set ( $foreachCount = 10 )
#macro(VelListToJSON $list )
#set($myList = $list )## dereference
{
#foreach($key in $myList.keySet())
"$key":
#set($x = $myList.get($key))
#VelToJSON($x)
#if($foreachCount != $myList.keySet().size()) , #end
#end
}
#end
#macro(VelArrayToJSON $arr)
#set($myArr = $arr)
[
#foreach($x in $myArr)
#VelToJSON($x)
#if($foreachCount != $myArr.size()) , #end
#end
]
#end
#macro(VelToJSON $item)
#if($map_class.isAssignableFrom($item.class))
#VelListToJSON($item)
#elseif($list_class.isAssignableFrom($item.class))
#VelArrayToJSON($item)
#elseif($bool_class.isAssignableFrom($item.class)|| $int_class.isAssignableFrom($item.class))
$item
#else ## $string_class.isAssignableFrom($item.class)
"$item"
#end
#end
Edited by: crowdblink on Mar 23, 2021 12:00 PM
Relevant content
- asked 6 years ago
- AWS OFFICIALUpdated 4 years ago