sheadawson / silverstripe-shortcodable

Provides a GUI for CMS users to insert Shortcodes into the HTMLEditorField + an API for developers to define Shortcodable DataObjects and Views.
MIT License
48 stars 36 forks source link

Does not save to DB when template is empty #63

Open faloude opened 6 years ago

faloude commented 6 years ago

Found out a strange reproducable error.

When the template which is used to render the shortcodable dataobject is empty, the shortcode will not be saved to the DB. When I type a simple 'Foo' in the template file, the bug vanishes.

public static function parse_shortcode($attributes, $content, $parser, $shortcode) {

    if (isset($attributes['id']) && $map = self::get()->byID($attributes['id'])) {
        return $map->customise($data)->renderWith('Map'); // Map.ss cannot be empty
    }
}
wernerkrauss commented 6 years ago

Isn't that a good start to write a unit test that prooves this wrong behaviour?

faloude commented 6 years ago

I've never written one before.