1

I'm currently writing a module to write HTML content for my MATLAB project. To keep flexibility, I wrote my code like this :

function content = get_content(obj, elements)
    % Return the HTML of the page
    body_content = obj.get_body(elements);
    header_content = obj.get_header();
    content = {
        header_content{:} ...
        body_content{:} ...
        '</html>' ...
    };
end
function content = get_header(obj, elements)
    content = {
        '<!DOCTYPE html>' ...
        '<html lang="en">' ...
        '<head>' ...
        '    <meta charset="utf-8" />' ...
        '    <title>Report</title>' ...
        '    ' ...
        '    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">' ...
        '    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>' ...
        '    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>' ...
        '    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>' ...
        '    ' ...
            obj.css{:} ...
        '</head>' ...
    }
end
% ....  

So, my issue appears when I try to concat the content returned by another function Currently I have to do this :

function content = get_content(obj, elements)
    % Return the HTML of the page
    body_content = obj.get_body(elements);
    header_content = obj.get_header();
    content = {
        header_content{:} ...
        body_content{:} ...
        '</html>' ...
    };
end

But, I would like to have everything on the same line, like this :

function content = get_content(obj, elements)
    % Return the HTML of the page
    content = {
        obj.get_header(){:} ...
        obj.get_body(elements){:} ...
        '</html>' ...
    };
end

Obviously, when I do this, I have the following error :

    ()-indexing must appear last in an index expression.

Do you have a simple way/hack to do something like this ?

Regards

graille
  • 1,131
  • 2
  • 14
  • 33

0 Answers0