using put on a map in velocity prints the instruction [duplicate]





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0
















This question already has an answer here:




  • Velocity Template engine - key-value-map

    2 answers




I have a map in a velocity template that is dynamically modified. A simplified example to illustrate the point is below.



#set($testMap = {})

## this stuff isn't static so I can't just create
## the map as key-value pairs in the declaration

$testMap.put("a", "A")
$testMap.put("b", "B")

$testMap


The above generates





$testMap.put("a", "A") $testMap.put("b", "B") {a=A, b=B}





I don't want the "put" instructions to show in the template.










share|improve this question













marked as duplicate by William Burnham, Community Jan 3 at 12:03


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • Are you looking for this stackoverflow.com/questions/16398116/…?

    – soorapadman
    Jan 3 at 10:51


















0
















This question already has an answer here:




  • Velocity Template engine - key-value-map

    2 answers




I have a map in a velocity template that is dynamically modified. A simplified example to illustrate the point is below.



#set($testMap = {})

## this stuff isn't static so I can't just create
## the map as key-value pairs in the declaration

$testMap.put("a", "A")
$testMap.put("b", "B")

$testMap


The above generates





$testMap.put("a", "A") $testMap.put("b", "B") {a=A, b=B}





I don't want the "put" instructions to show in the template.










share|improve this question













marked as duplicate by William Burnham, Community Jan 3 at 12:03


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.



















  • Are you looking for this stackoverflow.com/questions/16398116/…?

    – soorapadman
    Jan 3 at 10:51














0












0








0









This question already has an answer here:




  • Velocity Template engine - key-value-map

    2 answers




I have a map in a velocity template that is dynamically modified. A simplified example to illustrate the point is below.



#set($testMap = {})

## this stuff isn't static so I can't just create
## the map as key-value pairs in the declaration

$testMap.put("a", "A")
$testMap.put("b", "B")

$testMap


The above generates





$testMap.put("a", "A") $testMap.put("b", "B") {a=A, b=B}





I don't want the "put" instructions to show in the template.










share|improve this question















This question already has an answer here:




  • Velocity Template engine - key-value-map

    2 answers




I have a map in a velocity template that is dynamically modified. A simplified example to illustrate the point is below.



#set($testMap = {})

## this stuff isn't static so I can't just create
## the map as key-value pairs in the declaration

$testMap.put("a", "A")
$testMap.put("b", "B")

$testMap


The above generates





$testMap.put("a", "A") $testMap.put("b", "B") {a=A, b=B}





I don't want the "put" instructions to show in the template.





This question already has an answer here:




  • Velocity Template engine - key-value-map

    2 answers








velocity






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 3 at 10:12









William BurnhamWilliam Burnham

2,6481720




2,6481720




marked as duplicate by William Burnham, Community Jan 3 at 12:03


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









marked as duplicate by William Burnham, Community Jan 3 at 12:03


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.















  • Are you looking for this stackoverflow.com/questions/16398116/…?

    – soorapadman
    Jan 3 at 10:51



















  • Are you looking for this stackoverflow.com/questions/16398116/…?

    – soorapadman
    Jan 3 at 10:51

















Are you looking for this stackoverflow.com/questions/16398116/…?

– soorapadman
Jan 3 at 10:51





Are you looking for this stackoverflow.com/questions/16398116/…?

– soorapadman
Jan 3 at 10:51












2 Answers
2






active

oldest

votes


















0














I suggest you initialize your map with entries:



#set (testMap = {"a" :  "A" , "b" : "B"})





share|improve this answer
























  • Hi, thanks for your input. I would have liked to do that but the map's contents aren't known when it's initialized; the put instructions are done later dynamically inside of a loop and a few conditions.

    – William Burnham
    Jan 3 at 10:19



















0














To stop it from printing the instruction, I used dummy assignment variables



#set($testMap = {})

## this stuff isn't static so I can't just create
## the map as key-value pairs in the declaration

#set($tmp = $testMap.put("a", "A"))
#set($tmp = $testMap.put("b", "B"))

$testMap


This prints





{a=A, b=B}





A similar question is here.



I don't think it's a duplicate; Map.put(K, V) returns the V which isn't the same as the string literal $testMap.put("a", "A").






share|improve this answer






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I suggest you initialize your map with entries:



    #set (testMap = {"a" :  "A" , "b" : "B"})





    share|improve this answer
























    • Hi, thanks for your input. I would have liked to do that but the map's contents aren't known when it's initialized; the put instructions are done later dynamically inside of a loop and a few conditions.

      – William Burnham
      Jan 3 at 10:19
















    0














    I suggest you initialize your map with entries:



    #set (testMap = {"a" :  "A" , "b" : "B"})





    share|improve this answer
























    • Hi, thanks for your input. I would have liked to do that but the map's contents aren't known when it's initialized; the put instructions are done later dynamically inside of a loop and a few conditions.

      – William Burnham
      Jan 3 at 10:19














    0












    0








    0







    I suggest you initialize your map with entries:



    #set (testMap = {"a" :  "A" , "b" : "B"})





    share|improve this answer













    I suggest you initialize your map with entries:



    #set (testMap = {"a" :  "A" , "b" : "B"})






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Jan 3 at 10:18









    user7294900user7294900

    24.2k123565




    24.2k123565













    • Hi, thanks for your input. I would have liked to do that but the map's contents aren't known when it's initialized; the put instructions are done later dynamically inside of a loop and a few conditions.

      – William Burnham
      Jan 3 at 10:19



















    • Hi, thanks for your input. I would have liked to do that but the map's contents aren't known when it's initialized; the put instructions are done later dynamically inside of a loop and a few conditions.

      – William Burnham
      Jan 3 at 10:19

















    Hi, thanks for your input. I would have liked to do that but the map's contents aren't known when it's initialized; the put instructions are done later dynamically inside of a loop and a few conditions.

    – William Burnham
    Jan 3 at 10:19





    Hi, thanks for your input. I would have liked to do that but the map's contents aren't known when it's initialized; the put instructions are done later dynamically inside of a loop and a few conditions.

    – William Burnham
    Jan 3 at 10:19













    0














    To stop it from printing the instruction, I used dummy assignment variables



    #set($testMap = {})

    ## this stuff isn't static so I can't just create
    ## the map as key-value pairs in the declaration

    #set($tmp = $testMap.put("a", "A"))
    #set($tmp = $testMap.put("b", "B"))

    $testMap


    This prints





    {a=A, b=B}





    A similar question is here.



    I don't think it's a duplicate; Map.put(K, V) returns the V which isn't the same as the string literal $testMap.put("a", "A").






    share|improve this answer




























      0














      To stop it from printing the instruction, I used dummy assignment variables



      #set($testMap = {})

      ## this stuff isn't static so I can't just create
      ## the map as key-value pairs in the declaration

      #set($tmp = $testMap.put("a", "A"))
      #set($tmp = $testMap.put("b", "B"))

      $testMap


      This prints





      {a=A, b=B}





      A similar question is here.



      I don't think it's a duplicate; Map.put(K, V) returns the V which isn't the same as the string literal $testMap.put("a", "A").






      share|improve this answer


























        0












        0








        0







        To stop it from printing the instruction, I used dummy assignment variables



        #set($testMap = {})

        ## this stuff isn't static so I can't just create
        ## the map as key-value pairs in the declaration

        #set($tmp = $testMap.put("a", "A"))
        #set($tmp = $testMap.put("b", "B"))

        $testMap


        This prints





        {a=A, b=B}





        A similar question is here.



        I don't think it's a duplicate; Map.put(K, V) returns the V which isn't the same as the string literal $testMap.put("a", "A").






        share|improve this answer













        To stop it from printing the instruction, I used dummy assignment variables



        #set($testMap = {})

        ## this stuff isn't static so I can't just create
        ## the map as key-value pairs in the declaration

        #set($tmp = $testMap.put("a", "A"))
        #set($tmp = $testMap.put("b", "B"))

        $testMap


        This prints





        {a=A, b=B}





        A similar question is here.



        I don't think it's a duplicate; Map.put(K, V) returns the V which isn't the same as the string literal $testMap.put("a", "A").







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 3 at 10:18









        William BurnhamWilliam Burnham

        2,6481720




        2,6481720















            Popular posts from this blog

            android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

            SQL update select statement

            'app-layout' is not a known element: how to share Component with different Modules