Resolving variables inside a Coldfusion string

后端 未结 4 680
长情又很酷
长情又很酷 2021-01-14 00:28

My client has a database table of email bodies that get sent at certain times to customers. The text for the emails contains ColdFusion expressions like Dear #firstName# and

4条回答
  •  渐次进展
    2021-01-14 01:22

    What other languages often do that seems to work very well is just have some kind of token within your template that can be easily replaced by a regular expression. So you might have a template like:

    Dear {{name}}, Thanks for trying {{product_name}}.  Etc...
    

    And then you can simply:

    
    

    And when you want to get fancier you could just write a method to wrap this:

    
        
        
    
        
        
    
        
            
        
    
        
    
    

    And use it like so:

    
    
    

提交回复
热议问题