Is it possible to add tags to each new line of a text area?

  • Question is in the subject... am building a simple html description list to be edited by the user but would like it to be possible to have multiple <dd></dd> pairs under some of the <dt></dt> pairs... I'd like to keep the editor interface as simple as possible here so for me the easiest thing would be a Textarea that in the template adds <dd></dd> tags to each new line.


    Is this something that can be achieved simply within perch or do I need to write some sort of basic .js and set it up as an editor? (Not something that I would know how to do but might be worth the learning experience if it's a sane approach.)


    Or is there another way entirely I should be trying to do this? I'd rather not go down the route of nested blocks / repeaters for it...

  • drewm

    Approved the thread.
  • You could do it with a textarea field if you wrote a template filter to process the result. It would be very simple to do, something like

    Code
    1. return implode("\n", array_map(function($line){
    2.     return '<dd>'.$line.'</dd>';
    3. }, explode("\n", $value));