# Using blade templates with WP Blocks

**URL:** https://discourse.roots.io/t/using-blade-templates-with-wp-blocks/25608
**Category:** sage
**Tags:** gutenberg, sage10, sage9
**Created:** 2023-07-01T19:38:24Z
**Posts:** 3

## Post 1 by @nbyloff — 2023-07-01T19:38:24Z

I have old WP\_Widget classes I am working to update to WP Blocks using ACF Blocks. It works fine except for the rendering. Previously in the `WP_Widget` class, I just rendered content like this:

```
/**
         * Outputs the content of the widget
         *
         * @param array $args
         * @param array $instance
         */
        public function widget($args, $instance)
        {
           ...
           ...
           ...
            // outputs the content of the widget
            echo \Roots\view('partials.sidebars.newsletter-signup', $args);
        }
```

It let me use View composers and all the other blade templating features.

Now I have a block.json file for this widget and I tried to use the ` renderCallback` option [mentioned here](https://www.advancedcustomfields.com/resources/acf-blocks-with-block-json/#acf-configuration-key) like this:

```
// file is located in resources/views/blocks/newsletter.blade.php
function newsletter_block_render_callback($block)
{
    // outputs the content of the widget
    return \Roots\view('blocks.newsletter');
}
```

I tried multiple different paths, including views & resources/views/. I have also tried echo instead of return. None of it works.

If I use the `renderTemplate` option like this:

```
"renderTemplate": "resources/views/blocks/newsletter.blade.php"
```

It loads the template properly. However, I cannot use any blade functionality like ` @php` `@if` or `{{ $var }}`. It requires me to use the `<?php` tags and `echo` any PHP variable.

So it does work, but if I can keep consistency across the theme and use the blade rendering templates instead of `echo` and `<?php` blocks like in the [example here](https://www.advancedcustomfields.com/resources/blocks/#blockstestimonialtestimonialphp), that would be preferred.

---

## Post 2 by @ben — 2023-07-01T22:33:24Z

See [Rendering Blade Views | Acorn Docs | Roots](https://roots.io/acorn/docs/rendering-blade-views/)

---

## Post 3 by @nbyloff — 2023-07-01T22:40:44Z

Perfect, thank you! I was relying on Google too much to find the answer and didn’t consider going through the acorn docs.
